aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpufreq/cpufreq.c55
-rw-r--r--drivers/hid/Kconfig70
-rw-r--r--drivers/hid/Makefile5
-rw-r--r--drivers/hid/hid-bright.c71
-rw-r--r--drivers/hid/hid-core.c120
-rw-r--r--drivers/hid/hid-dell.c76
-rw-r--r--drivers/hid/hid-dummy.c6
-rw-r--r--drivers/hid/hid-gaff.c185
-rw-r--r--drivers/hid/hid-ids.h21
-rw-r--r--drivers/hid/hid-lg.c7
-rw-r--r--drivers/hid/hid-ntrig.c82
-rw-r--r--drivers/hid/hid-sony.c2
-rw-r--r--drivers/hid/hid-topseed.c77
-rw-r--r--drivers/hid/hidraw.c32
-rw-r--r--drivers/hid/usbhid/Kconfig2
-rw-r--r--drivers/hid/usbhid/hid-core.c34
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hid/usbhid/hiddev.c135
-rw-r--r--drivers/hid/usbhid/usbhid.h10
-rw-r--r--drivers/i2c/busses/i2c-omap.c420
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c185
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c3
-rw-r--r--drivers/isdn/capi/capidrv.c4
-rw-r--r--drivers/isdn/capi/capifs.c2
-rw-r--r--drivers/message/i2o/exec-osm.c2
-rw-r--r--drivers/message/i2o/i2o_config.c2
-rw-r--r--drivers/message/i2o/iop.c2
-rw-r--r--drivers/message/i2o/pci.c2
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c2
-rw-r--r--drivers/net/acenic.c117
-rw-r--r--drivers/net/acenic.h4
-rw-r--r--drivers/net/e100.c268
-rw-r--r--drivers/net/ehea/ehea.h3
-rw-r--r--drivers/net/ehea/ehea_main.c2
-rw-r--r--drivers/net/enc28j60.c4
-rw-r--r--drivers/net/igb/igb_main.c4
-rw-r--r--drivers/net/myri10ge/myri10ge.c6
-rw-r--r--drivers/net/qlge/qlge.h57
-rw-r--r--drivers/net/qlge/qlge_dbg.c13
-rw-r--r--drivers/net/qlge/qlge_ethtool.c8
-rw-r--r--drivers/net/qlge/qlge_main.c116
-rw-r--r--drivers/net/starfire.c54
-rw-r--r--drivers/net/starfire_firmware.h346
-rw-r--r--drivers/net/starfire_firmware.pl31
-rw-r--r--drivers/net/tg3.c792
-rw-r--r--drivers/net/tg3.h4
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/oprofile/oprofilefs.c3
-rw-r--r--drivers/rtc/Kconfig6
-rw-r--r--drivers/rtc/interface.c54
-rw-r--r--drivers/rtc/rtc-dev.c51
-rw-r--r--drivers/s390/net/qeth_core.h1
-rw-r--r--drivers/s390/net/qeth_core_main.c57
-rw-r--r--drivers/s390/net/qeth_l2_main.c8
-rw-r--r--drivers/s390/net/qeth_l3_main.c26
-rw-r--r--drivers/usb/core/inode.c1
-rw-r--r--drivers/usb/gadget/file_storage.c18
-rw-r--r--drivers/usb/gadget/inode.c1
-rw-r--r--drivers/video/via/viafbdev.c248
59 files changed, 1856 insertions, 2064 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 31d6f535a79d..01dde80597f7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -754,6 +754,11 @@ static struct kobj_type ktype_cpufreq = {
754 .release = cpufreq_sysfs_release, 754 .release = cpufreq_sysfs_release,
755}; 755};
756 756
757static struct kobj_type ktype_empty_cpufreq = {
758 .sysfs_ops = &sysfs_ops,
759 .release = cpufreq_sysfs_release,
760};
761
757 762
758/** 763/**
759 * cpufreq_add_dev - add a CPU device 764 * cpufreq_add_dev - add a CPU device
@@ -822,8 +827,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
822 dprintk("initialization failed\n"); 827 dprintk("initialization failed\n");
823 goto err_out; 828 goto err_out;
824 } 829 }
825 policy->user_policy.min = policy->cpuinfo.min_freq; 830 policy->user_policy.min = policy->min;
826 policy->user_policy.max = policy->cpuinfo.max_freq; 831 policy->user_policy.max = policy->max;
827 832
828 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 833 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
829 CPUFREQ_START, policy); 834 CPUFREQ_START, policy);
@@ -876,26 +881,36 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
876 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); 881 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
877 882
878 /* prepare interface data */ 883 /* prepare interface data */
879 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj, 884 if (!cpufreq_driver->hide_interface) {
880 "cpufreq"); 885 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
881 if (ret) 886 &sys_dev->kobj, "cpufreq");
882 goto err_out_driver_exit;
883
884 /* set up files for this cpu device */
885 drv_attr = cpufreq_driver->attr;
886 while ((drv_attr) && (*drv_attr)) {
887 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
888 if (ret) 887 if (ret)
889 goto err_out_driver_exit; 888 goto err_out_driver_exit;
890 drv_attr++; 889
891 } 890 /* set up files for this cpu device */
892 if (cpufreq_driver->get) { 891 drv_attr = cpufreq_driver->attr;
893 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 892 while ((drv_attr) && (*drv_attr)) {
894 if (ret) 893 ret = sysfs_create_file(&policy->kobj,
895 goto err_out_driver_exit; 894 &((*drv_attr)->attr));
896 } 895 if (ret)
897 if (cpufreq_driver->target) { 896 goto err_out_driver_exit;
898 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 897 drv_attr++;
898 }
899 if (cpufreq_driver->get) {
900 ret = sysfs_create_file(&policy->kobj,
901 &cpuinfo_cur_freq.attr);
902 if (ret)
903 goto err_out_driver_exit;
904 }
905 if (cpufreq_driver->target) {
906 ret = sysfs_create_file(&policy->kobj,
907 &scaling_cur_freq.attr);
908 if (ret)
909 goto err_out_driver_exit;
910 }
911 } else {
912 ret = kobject_init_and_add(&policy->kobj, &ktype_empty_cpufreq,
913 &sys_dev->kobj, "cpufreq");
899 if (ret) 914 if (ret)
900 goto err_out_driver_exit; 915 goto err_out_driver_exit;
901 } 916 }
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index b4fd8ca701a4..e85c8fe9ffcf 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -85,14 +85,14 @@ config HID_COMPAT
85config HID_A4TECH 85config HID_A4TECH
86 tristate "A4 tech" if EMBEDDED 86 tristate "A4 tech" if EMBEDDED
87 depends on USB_HID 87 depends on USB_HID
88 default y 88 default !EMBEDDED
89 ---help--- 89 ---help---
90 Support for A4 tech X5 and WOP-35 / Trust 450L mice. 90 Support for A4 tech X5 and WOP-35 / Trust 450L mice.
91 91
92config HID_APPLE 92config HID_APPLE
93 tristate "Apple" if EMBEDDED 93 tristate "Apple" if EMBEDDED
94 depends on (USB_HID || BT_HIDP) 94 depends on (USB_HID || BT_HIDP)
95 default y 95 default !EMBEDDED
96 ---help--- 96 ---help---
97 Support for some Apple devices which less or more break 97 Support for some Apple devices which less or more break
98 HID specification. 98 HID specification.
@@ -103,64 +103,49 @@ config HID_APPLE
103config HID_BELKIN 103config HID_BELKIN
104 tristate "Belkin" if EMBEDDED 104 tristate "Belkin" if EMBEDDED
105 depends on USB_HID 105 depends on USB_HID
106 default y 106 default !EMBEDDED
107 ---help--- 107 ---help---
108 Support for Belkin Flip KVM and Wireless keyboard. 108 Support for Belkin Flip KVM and Wireless keyboard.
109 109
110config HID_BRIGHT
111 tristate "Bright" if EMBEDDED
112 depends on USB_HID
113 default y
114 ---help---
115 Support for Bright ABNT-2 keyboard.
116
117config HID_CHERRY 110config HID_CHERRY
118 tristate "Cherry" if EMBEDDED 111 tristate "Cherry" if EMBEDDED
119 depends on USB_HID 112 depends on USB_HID
120 default y 113 default !EMBEDDED
121 ---help--- 114 ---help---
122 Support for Cherry Cymotion keyboard. 115 Support for Cherry Cymotion keyboard.
123 116
124config HID_CHICONY 117config HID_CHICONY
125 tristate "Chicony" if EMBEDDED 118 tristate "Chicony" if EMBEDDED
126 depends on USB_HID 119 depends on USB_HID
127 default y 120 default !EMBEDDED
128 ---help--- 121 ---help---
129 Support for Chicony Tactical pad. 122 Support for Chicony Tactical pad.
130 123
131config HID_CYPRESS 124config HID_CYPRESS
132 tristate "Cypress" if EMBEDDED 125 tristate "Cypress" if EMBEDDED
133 depends on USB_HID 126 depends on USB_HID
134 default y 127 default !EMBEDDED
135 ---help--- 128 ---help---
136 Support for cypress mouse and barcode readers. 129 Support for cypress mouse and barcode readers.
137 130
138config HID_DELL
139 tristate "Dell" if EMBEDDED
140 depends on USB_HID
141 default y
142 ---help---
143 Support for quirky Dell HID hardware that require
144 special LED handling (W7658 and SK8115 models)
145
146config HID_EZKEY 131config HID_EZKEY
147 tristate "Ezkey" if EMBEDDED 132 tristate "Ezkey" if EMBEDDED
148 depends on USB_HID 133 depends on USB_HID
149 default y 134 default !EMBEDDED
150 ---help--- 135 ---help---
151 Support for Ezkey BTC 8193 keyboard. 136 Support for Ezkey BTC 8193 keyboard.
152 137
153config HID_GYRATION 138config HID_GYRATION
154 tristate "Gyration" if EMBEDDED 139 tristate "Gyration" if EMBEDDED
155 depends on USB_HID 140 depends on USB_HID
156 default y 141 default !EMBEDDED
157 ---help--- 142 ---help---
158 Support for Gyration remote control. 143 Support for Gyration remote control.
159 144
160config HID_LOGITECH 145config HID_LOGITECH
161 tristate "Logitech" if EMBEDDED 146 tristate "Logitech" if EMBEDDED
162 depends on USB_HID 147 depends on USB_HID
163 default y 148 default !EMBEDDED
164 ---help--- 149 ---help---
165 Support for Logitech devices that are not fully compliant with HID standard. 150 Support for Logitech devices that are not fully compliant with HID standard.
166 151
@@ -191,21 +176,28 @@ config LOGIRUMBLEPAD2_FF
191config HID_MICROSOFT 176config HID_MICROSOFT
192 tristate "Microsoft" if EMBEDDED 177 tristate "Microsoft" if EMBEDDED
193 depends on USB_HID 178 depends on USB_HID
194 default y 179 default !EMBEDDED
195 ---help--- 180 ---help---
196 Support for Microsoft devices that are not fully compliant with HID standard. 181 Support for Microsoft devices that are not fully compliant with HID standard.
197 182
198config HID_MONTEREY 183config HID_MONTEREY
199 tristate "Monterey" if EMBEDDED 184 tristate "Monterey" if EMBEDDED
200 depends on USB_HID 185 depends on USB_HID
201 default y 186 default !EMBEDDED
202 ---help--- 187 ---help---
203 Support for Monterey Genius KB29E. 188 Support for Monterey Genius KB29E.
204 189
190config HID_NTRIG
191 tristate "NTrig" if EMBEDDED
192 depends on USB_HID
193 default !EMBEDDED
194 ---help---
195 Support for N-Trig touch screen.
196
205config HID_PANTHERLORD 197config HID_PANTHERLORD
206 tristate "Pantherlord devices support" if EMBEDDED 198 tristate "Pantherlord devices support" if EMBEDDED
207 depends on USB_HID 199 depends on USB_HID
208 default y 200 default !EMBEDDED
209 ---help--- 201 ---help---
210 Support for PantherLord/GreenAsia based device support. 202 Support for PantherLord/GreenAsia based device support.
211 203
@@ -220,31 +212,47 @@ config PANTHERLORD_FF
220config HID_PETALYNX 212config HID_PETALYNX
221 tristate "Petalynx" if EMBEDDED 213 tristate "Petalynx" if EMBEDDED
222 depends on USB_HID 214 depends on USB_HID
223 default y 215 default !EMBEDDED
224 ---help--- 216 ---help---
225 Support for Petalynx Maxter remote control. 217 Support for Petalynx Maxter remote control.
226 218
227config HID_SAMSUNG 219config HID_SAMSUNG
228 tristate "Samsung" if EMBEDDED 220 tristate "Samsung" if EMBEDDED
229 depends on USB_HID 221 depends on USB_HID
230 default y 222 default !EMBEDDED
231 ---help--- 223 ---help---
232 Support for Samsung InfraRed remote control. 224 Support for Samsung InfraRed remote control.
233 225
234config HID_SONY 226config HID_SONY
235 tristate "Sony" if EMBEDDED 227 tristate "Sony" if EMBEDDED
236 depends on USB_HID 228 depends on USB_HID
237 default y 229 default !EMBEDDED
238 ---help--- 230 ---help---
239 Support for Sony PS3 controller. 231 Support for Sony PS3 controller.
240 232
241config HID_SUNPLUS 233config HID_SUNPLUS
242 tristate "Sunplus" if EMBEDDED 234 tristate "Sunplus" if EMBEDDED
243 depends on USB_HID 235 depends on USB_HID
244 default y 236 default !EMBEDDED
245 ---help--- 237 ---help---
246 Support for Sunplus wireless desktop. 238 Support for Sunplus wireless desktop.
247 239
240config GREENASIA_FF
241 tristate "GreenAsia (Product ID 0x12) force feedback support"
242 depends on USB_HID
243 select INPUT_FF_MEMLESS
244 ---help---
245 Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
246 (like MANTA Warior MM816 and SpeedLink Strike2 SL-6635) or adapter
247 and want to enable force feedback support for it.
248
249config HID_TOPSEED
250 tristate "TopSeed Cyberlink remote control support" if EMBEDDED
251 depends on USB_HID
252 default !EMBEDDED
253 ---help---
254 Say Y if you have a TopSeed Cyberlink remote control.
255
248config THRUSTMASTER_FF 256config THRUSTMASTER_FF
249 tristate "ThrustMaster devices support" 257 tristate "ThrustMaster devices support"
250 depends on USB_HID 258 depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index b09e43e7413e..fbd021f153f1 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -23,22 +23,23 @@ endif
23obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o 23obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
24obj-$(CONFIG_HID_APPLE) += hid-apple.o 24obj-$(CONFIG_HID_APPLE) += hid-apple.o
25obj-$(CONFIG_HID_BELKIN) += hid-belkin.o 25obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
26obj-$(CONFIG_HID_BRIGHT) += hid-bright.o
27obj-$(CONFIG_HID_CHERRY) += hid-cherry.o 26obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
28obj-$(CONFIG_HID_CHICONY) += hid-chicony.o 27obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
29obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o 28obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
30obj-$(CONFIG_HID_DELL) += hid-dell.o
31obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 29obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
32obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 30obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
33obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o 31obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
34obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o 32obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
35obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o 33obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
34obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
36obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o 35obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
37obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o 36obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
38obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o 37obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
39obj-$(CONFIG_HID_SONY) += hid-sony.o 38obj-$(CONFIG_HID_SONY) += hid-sony.o
40obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o 39obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
40obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o
41obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o 41obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o
42obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o
42obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o 43obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o
43 44
44obj-$(CONFIG_USB_HID) += usbhid/ 45obj-$(CONFIG_USB_HID) += usbhid/
diff --git a/drivers/hid/hid-bright.c b/drivers/hid/hid-bright.c
deleted file mode 100644
index 38517a117dfd..000000000000
--- a/drivers/hid/hid-bright.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * HID driver for some bright "special" devices
3 *
4 * Copyright (c) 2008 Mauro Carvalho Chehab <mchehab@redhat.com>
5 *
6 * Based on hid-dell driver
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15
16#include <linux/device.h>
17#include <linux/hid.h>
18#include <linux/module.h>
19
20#include "hid-ids.h"
21
22static int bright_probe(struct hid_device *hdev, const struct hid_device_id *id)
23{
24 int ret;
25
26 ret = hid_parse(hdev);
27 if (ret) {
28 dev_err(&hdev->dev, "parse failed\n");
29 goto err_free;
30 }
31
32 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
33 if (ret) {
34 dev_err(&hdev->dev, "hw start failed\n");
35 goto err_free;
36 }
37
38 usbhid_set_leds(hdev);
39
40 return 0;
41err_free:
42 return ret;
43}
44
45static const struct hid_device_id bright_devices[] = {
46 { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) },
47 { }
48};
49MODULE_DEVICE_TABLE(hid, bright_devices);
50
51static struct hid_driver bright_driver = {
52 .name = "bright",
53 .id_table = bright_devices,
54 .probe = bright_probe,
55};
56
57static int bright_init(void)
58{
59 return hid_register_driver(&bright_driver);
60}
61
62static void bright_exit(void)
63{
64 hid_unregister_driver(&bright_driver);
65}
66
67module_init(bright_init);
68module_exit(bright_exit);
69MODULE_LICENSE("GPL");
70
71HID_COMPAT_LOAD_DRIVER(bright);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 40df3e1b4bd1..5d7640e49dc5 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1256,19 +1256,16 @@ static const struct hid_device_id hid_blacklist[] = {
1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1257 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1257 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1258 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1258 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
1259 { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) },
1260 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 1259 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
1261 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1260 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
1262 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 1261 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1263 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1262 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
1264 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1263 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
1265 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) },
1266 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) },
1267 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1264 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1268 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) },
1269 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1265 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
1270 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 1266 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
1271 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 1267 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
1268 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
1272 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 1269 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
1273 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1270 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
1274 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 1271 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
@@ -1279,7 +1276,6 @@ static const struct hid_device_id hid_blacklist[] = {
1279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 1276 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
1280 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 1277 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
1281 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 1278 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
1282 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD) },
1283 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 1279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) },
1284 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 1280 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
1285 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 1281 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) },
@@ -1297,23 +1293,105 @@ static const struct hid_device_id hid_blacklist[] = {
1297 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1293 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1294 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
1299 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1295 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
1296 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
1300 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1297 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1301 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1298 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1302 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1299 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1303 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1300 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
1304 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1301 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
1302 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
1305 1303
1306 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) }, 1304 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) },
1307 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 1305 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
1308 { } 1306 { }
1309}; 1307};
1310 1308
1309struct hid_dynid {
1310 struct list_head list;
1311 struct hid_device_id id;
1312};
1313
1314/**
1315 * store_new_id - add a new HID device ID to this driver and re-probe devices
1316 * @driver: target device driver
1317 * @buf: buffer for scanning device ID data
1318 * @count: input size
1319 *
1320 * Adds a new dynamic hid device ID to this driver,
1321 * and causes the driver to probe for all devices again.
1322 */
1323static ssize_t store_new_id(struct device_driver *drv, const char *buf,
1324 size_t count)
1325{
1326 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1327 struct hid_dynid *dynid;
1328 __u32 bus, vendor, product;
1329 unsigned long driver_data = 0;
1330 int ret;
1331
1332 ret = sscanf(buf, "%x %x %x %lx",
1333 &bus, &vendor, &product, &driver_data);
1334 if (ret < 3)
1335 return -EINVAL;
1336
1337 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
1338 if (!dynid)
1339 return -ENOMEM;
1340
1341 dynid->id.bus = bus;
1342 dynid->id.vendor = vendor;
1343 dynid->id.product = product;
1344 dynid->id.driver_data = driver_data;
1345
1346 spin_lock(&hdrv->dyn_lock);
1347 list_add_tail(&dynid->list, &hdrv->dyn_list);
1348 spin_unlock(&hdrv->dyn_lock);
1349
1350 ret = 0;
1351 if (get_driver(&hdrv->driver)) {
1352 ret = driver_attach(&hdrv->driver);
1353 put_driver(&hdrv->driver);
1354 }
1355
1356 return ret ? : count;
1357}
1358static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
1359
1360static void hid_free_dynids(struct hid_driver *hdrv)
1361{
1362 struct hid_dynid *dynid, *n;
1363
1364 spin_lock(&hdrv->dyn_lock);
1365 list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) {
1366 list_del(&dynid->list);
1367 kfree(dynid);
1368 }
1369 spin_unlock(&hdrv->dyn_lock);
1370}
1371
1372static const struct hid_device_id *hid_match_device(struct hid_device *hdev,
1373 struct hid_driver *hdrv)
1374{
1375 struct hid_dynid *dynid;
1376
1377 spin_lock(&hdrv->dyn_lock);
1378 list_for_each_entry(dynid, &hdrv->dyn_list, list) {
1379 if (hid_match_one_id(hdev, &dynid->id)) {
1380 spin_unlock(&hdrv->dyn_lock);
1381 return &dynid->id;
1382 }
1383 }
1384 spin_unlock(&hdrv->dyn_lock);
1385
1386 return hid_match_id(hdev, hdrv->id_table);
1387}
1388
1311static int hid_bus_match(struct device *dev, struct device_driver *drv) 1389static int hid_bus_match(struct device *dev, struct device_driver *drv)
1312{ 1390{
1313 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 1391 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1314 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1392 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1315 1393
1316 if (!hid_match_id(hdev, hdrv->id_table)) 1394 if (!hid_match_device(hdev, hdrv))
1317 return 0; 1395 return 0;
1318 1396
1319 /* generic wants all non-blacklisted */ 1397 /* generic wants all non-blacklisted */
@@ -1332,7 +1410,7 @@ static int hid_device_probe(struct device *dev)
1332 int ret = 0; 1410 int ret = 0;
1333 1411
1334 if (!hdev->driver) { 1412 if (!hdev->driver) {
1335 id = hid_match_id(hdev, hdrv->id_table); 1413 id = hid_match_device(hdev, hdrv);
1336 if (id == NULL) 1414 if (id == NULL)
1337 return -ENODEV; 1415 return -ENODEV;
1338 1416
@@ -1420,6 +1498,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1420 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1498 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
1421 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1499 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
1422 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 1500 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
1501 { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
1423 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1502 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1424 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1503 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
1425 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1504 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
@@ -1577,6 +1656,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
1577 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1656 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1578 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1657 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1579 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1658 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
1659 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1660 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1661 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
1580 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1662 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1581 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1663 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1582 { } 1664 { }
@@ -1618,9 +1700,10 @@ int hid_add_device(struct hid_device *hdev)
1618 if (hid_ignore(hdev)) 1700 if (hid_ignore(hdev))
1619 return -ENODEV; 1701 return -ENODEV;
1620 1702
1621 /* XXX hack, any other cleaner solution < 20 bus_id bytes? */ 1703 /* XXX hack, any other cleaner solution after the driver core
1622 sprintf(hdev->dev.bus_id, "%04X:%04X:%04X.%04X", hdev->bus, 1704 * is converted to allow more than 20 bytes as the device name? */
1623 hdev->vendor, hdev->product, atomic_inc_return(&id)); 1705 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
1706 hdev->vendor, hdev->product, atomic_inc_return(&id));
1624 1707
1625 ret = device_add(&hdev->dev); 1708 ret = device_add(&hdev->dev);
1626 if (!ret) 1709 if (!ret)
@@ -1695,18 +1778,33 @@ EXPORT_SYMBOL_GPL(hid_destroy_device);
1695int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 1778int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
1696 const char *mod_name) 1779 const char *mod_name)
1697{ 1780{
1781 int ret;
1782
1698 hdrv->driver.name = hdrv->name; 1783 hdrv->driver.name = hdrv->name;
1699 hdrv->driver.bus = &hid_bus_type; 1784 hdrv->driver.bus = &hid_bus_type;
1700 hdrv->driver.owner = owner; 1785 hdrv->driver.owner = owner;
1701 hdrv->driver.mod_name = mod_name; 1786 hdrv->driver.mod_name = mod_name;
1702 1787
1703 return driver_register(&hdrv->driver); 1788 INIT_LIST_HEAD(&hdrv->dyn_list);
1789 spin_lock_init(&hdrv->dyn_lock);
1790
1791 ret = driver_register(&hdrv->driver);
1792 if (ret)
1793 return ret;
1794
1795 ret = driver_create_file(&hdrv->driver, &driver_attr_new_id);
1796 if (ret)
1797 driver_unregister(&hdrv->driver);
1798
1799 return ret;
1704} 1800}
1705EXPORT_SYMBOL_GPL(__hid_register_driver); 1801EXPORT_SYMBOL_GPL(__hid_register_driver);
1706 1802
1707void hid_unregister_driver(struct hid_driver *hdrv) 1803void hid_unregister_driver(struct hid_driver *hdrv)
1708{ 1804{
1805 driver_remove_file(&hdrv->driver, &driver_attr_new_id);
1709 driver_unregister(&hdrv->driver); 1806 driver_unregister(&hdrv->driver);
1807 hid_free_dynids(hdrv);
1710} 1808}
1711EXPORT_SYMBOL_GPL(hid_unregister_driver); 1809EXPORT_SYMBOL_GPL(hid_unregister_driver);
1712 1810
diff --git a/drivers/hid/hid-dell.c b/drivers/hid/hid-dell.c
deleted file mode 100644
index f5474300b83a..000000000000
--- a/drivers/hid/hid-dell.c
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * HID driver for some dell "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 */
11
12/*
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 */
18
19#include <linux/device.h>
20#include <linux/hid.h>
21#include <linux/module.h>
22
23#include "hid-ids.h"
24
25static int dell_probe(struct hid_device *hdev, const struct hid_device_id *id)
26{
27 int ret;
28
29 ret = hid_parse(hdev);
30 if (ret) {
31 dev_err(&hdev->dev, "parse failed\n");
32 goto err_free;
33 }
34
35 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
36 if (ret) {
37 dev_err(&hdev->dev, "hw start failed\n");
38 goto err_free;
39 }
40
41 usbhid_set_leds(hdev);
42
43 return 0;
44err_free:
45 return ret;
46}
47
48static const struct hid_device_id dell_devices[] = {
49 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) },
50 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) },
51 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) },
52 { }
53};
54MODULE_DEVICE_TABLE(hid, dell_devices);
55
56static struct hid_driver dell_driver = {
57 .name = "dell",
58 .id_table = dell_devices,
59 .probe = dell_probe,
60};
61
62static int dell_init(void)
63{
64 return hid_register_driver(&dell_driver);
65}
66
67static void dell_exit(void)
68{
69 hid_unregister_driver(&dell_driver);
70}
71
72module_init(dell_init);
73module_exit(dell_exit);
74MODULE_LICENSE("GPL");
75
76HID_COMPAT_LOAD_DRIVER(dell);
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
index e148f86fb58e..b4cc0f743d63 100644
--- a/drivers/hid/hid-dummy.c
+++ b/drivers/hid/hid-dummy.c
@@ -43,6 +43,9 @@ static int __init hid_dummy_init(void)
43#ifdef CONFIG_HID_MONTEREY_MODULE 43#ifdef CONFIG_HID_MONTEREY_MODULE
44 HID_COMPAT_CALL_DRIVER(monterey); 44 HID_COMPAT_CALL_DRIVER(monterey);
45#endif 45#endif
46#ifdef CONFIG_HID_NTRIG_MODULE
47 HID_COMPAT_CALL_DRIVER(ntrig);
48#endif
46#ifdef CONFIG_HID_PANTHERLORD_MODULE 49#ifdef CONFIG_HID_PANTHERLORD_MODULE
47 HID_COMPAT_CALL_DRIVER(pantherlord); 50 HID_COMPAT_CALL_DRIVER(pantherlord);
48#endif 51#endif
@@ -58,6 +61,9 @@ static int __init hid_dummy_init(void)
58#ifdef CONFIG_HID_SUNPLUS_MODULE 61#ifdef CONFIG_HID_SUNPLUS_MODULE
59 HID_COMPAT_CALL_DRIVER(sunplus); 62 HID_COMPAT_CALL_DRIVER(sunplus);
60#endif 63#endif
64#ifdef CONFIG_GREENASIA_FF_MODULE
65 HID_COMPAT_CALL_DRIVER(greenasia);
66#endif
61#ifdef CONFIG_THRUSTMASTER_FF_MODULE 67#ifdef CONFIG_THRUSTMASTER_FF_MODULE
62 HID_COMPAT_CALL_DRIVER(thrustmaster); 68 HID_COMPAT_CALL_DRIVER(thrustmaster);
63#endif 69#endif
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
new file mode 100644
index 000000000000..71211f6a4f02
--- /dev/null
+++ b/drivers/hid/hid-gaff.c
@@ -0,0 +1,185 @@
1/*
2 * Force feedback support for GreenAsia (Product ID 0x12) based devices
3 *
4 * The devices are distributed under various names and the same USB device ID
5 * can be used in many game controllers.
6 *
7 *
8 * 0e8f:0012 "GreenAsia Inc. USB Joystick "
9 * - tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635.
10 *
11 * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
12 */
13
14/*
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30#include <linux/input.h>
31#include <linux/usb.h>
32#include <linux/hid.h>
33#include "hid-ids.h"
34#include "usbhid/usbhid.h"
35
36struct gaff_device {
37 struct hid_report *report;
38};
39
40static int hid_gaff_play(struct input_dev *dev, void *data,
41 struct ff_effect *effect)
42{
43 struct hid_device *hid = input_get_drvdata(dev);
44 struct gaff_device *gaff = data;
45 int left, right;
46
47 left = effect->u.rumble.strong_magnitude;
48 right = effect->u.rumble.weak_magnitude;
49
50 dbg_hid("called with 0x%04x 0x%04x", left, right);
51
52 left = left * 0xfe / 0xffff;
53 right = right * 0xfe / 0xffff;
54
55 gaff->report->field[0]->value[0] = 0x51;
56 gaff->report->field[0]->value[1] = 0x0;
57 gaff->report->field[0]->value[2] = right;
58 gaff->report->field[0]->value[3] = 0;
59 gaff->report->field[0]->value[4] = left;
60 gaff->report->field[0]->value[5] = 0;
61 dbg_hid("running with 0x%02x 0x%02x", left, right);
62 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
63
64 gaff->report->field[0]->value[0] = 0xfa;
65 gaff->report->field[0]->value[1] = 0xfe;
66 gaff->report->field[0]->value[2] = 0x0;
67 gaff->report->field[0]->value[4] = 0x0;
68
69 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
70
71 return 0;
72}
73
74static int gaff_init(struct hid_device *hid)
75{
76 struct gaff_device *gaff;
77 struct hid_report *report;
78 struct hid_input *hidinput = list_entry(hid->inputs.next,
79 struct hid_input, list);
80 struct list_head *report_list =
81 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
82 struct list_head *report_ptr = report_list;
83 struct input_dev *dev = hidinput->input;
84 int error;
85
86 if (list_empty(report_list)) {
87 dev_err(&hid->dev, "no output reports found\n");
88 return -ENODEV;
89 }
90
91 report_ptr = report_ptr->next;
92
93 report = list_entry(report_ptr, struct hid_report, list);
94 if (report->maxfield < 1) {
95 dev_err(&hid->dev, "no fields in the report\n");
96 return -ENODEV;
97 }
98
99 if (report->field[0]->report_count < 6) {
100 dev_err(&hid->dev, "not enough values in the field\n");
101 return -ENODEV;
102 }
103
104 gaff = kzalloc(sizeof(struct gaff_device), GFP_KERNEL);
105 if (!gaff)
106 return -ENOMEM;
107
108 set_bit(FF_RUMBLE, dev->ffbit);
109
110 error = input_ff_create_memless(dev, gaff, hid_gaff_play);
111 if (error) {
112 kfree(gaff);
113 return error;
114 }
115
116 gaff->report = report;
117 gaff->report->field[0]->value[0] = 0x51;
118 gaff->report->field[0]->value[1] = 0x00;
119 gaff->report->field[0]->value[2] = 0x00;
120 gaff->report->field[0]->value[3] = 0x00;
121 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
122
123 gaff->report->field[0]->value[0] = 0xfa;
124 gaff->report->field[0]->value[1] = 0xfe;
125
126 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
127
128 dev_info(&hid->dev, "Force Feedback for GreenAsia 0x12"
129 " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n");
130
131 return 0;
132}
133
134static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
135{
136 int ret;
137
138 dev_dbg(&hdev->dev, "Greenasia HID hardware probe...");
139
140 ret = hid_parse(hdev);
141 if (ret) {
142 dev_err(&hdev->dev, "parse failed\n");
143 goto err;
144 }
145
146 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
147 if (ret) {
148 dev_err(&hdev->dev, "hw start failed\n");
149 goto err;
150 }
151
152 gaff_init(hdev);
153
154 return 0;
155err:
156 return ret;
157}
158
159static const struct hid_device_id ga_devices[] = {
160 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012), },
161 { }
162};
163MODULE_DEVICE_TABLE(hid, ga_devices);
164
165static struct hid_driver ga_driver = {
166 .name = "greenasia",
167 .id_table = ga_devices,
168 .probe = ga_probe,
169};
170
171static int __init ga_init(void)
172{
173 return hid_register_driver(&ga_driver);
174}
175
176static void __exit ga_exit(void)
177{
178 hid_unregister_driver(&ga_driver);
179}
180
181module_init(ga_init);
182module_exit(ga_exit);
183MODULE_LICENSE("GPL");
184
185HID_COMPAT_LOAD_DRIVER(greenasia);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 39289699c32f..acc1abc834a4 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -107,9 +107,6 @@
107#define USB_VENDOR_ID_BELKIN 0x050d 107#define USB_VENDOR_ID_BELKIN 0x050d
108#define USB_DEVICE_ID_FLIP_KVM 0x3201 108#define USB_DEVICE_ID_FLIP_KVM 0x3201
109 109
110#define USB_VENDOR_ID_BRIGHT 0x1241
111#define USB_DEVICE_ID_BRIGHT_ABNT2 0x1503
112
113#define USB_VENDOR_ID_BERKSHIRE 0x0c98 110#define USB_VENDOR_ID_BERKSHIRE 0x0c98
114#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 111#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
115 112
@@ -141,9 +138,8 @@
141#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61 138#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
142#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64 139#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
143 140
144#define USB_VENDOR_ID_DELL 0x413c 141#define USB_VENDOR_ID_DEALEXTREAME 0x10c5
145#define USB_DEVICE_ID_DELL_W7658 0x2005 142#define USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701 0x819a
146#define USB_DEVICE_ID_DELL_SK8115 0x2105
147 143
148#define USB_VENDOR_ID_DELORME 0x1163 144#define USB_VENDOR_ID_DELORME 0x1163
149#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 145#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100
@@ -167,9 +163,6 @@
167 163
168#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc 164#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc
169 165
170#define USB_VENDOR_ID_GENERIC_13BA 0x13ba
171#define USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE 0x0017
172
173#define USB_VENDOR_ID_GLAB 0x06c2 166#define USB_VENDOR_ID_GLAB 0x06c2
174#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 167#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
175#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 168#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
@@ -292,7 +285,6 @@
292#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 285#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
293#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295 286#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295
294#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a 287#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a
295#define USB_DEVICE_ID_LOGITECH_KBD 0xc311
296#define USB_DEVICE_ID_S510_RECEIVER 0xc50c 288#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
297#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 289#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
298#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512 290#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
@@ -339,6 +331,9 @@
339#define USB_VENDOR_ID_NEC 0x073e 331#define USB_VENDOR_ID_NEC 0x073e
340#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301 332#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
341 333
334#define USB_VENDOR_ID_NTRIG 0x1b96
335#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001
336
342#define USB_VENDOR_ID_ONTRAK 0x0a07 337#define USB_VENDOR_ID_ONTRAK 0x0a07
343#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 338#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
344 339
@@ -383,9 +378,15 @@
383#define USB_VENDOR_ID_TOPMAX 0x0663 378#define USB_VENDOR_ID_TOPMAX 0x0663
384#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103 379#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
385 380
381#define USB_VENDOR_ID_TOPSEED 0x0766
382#define USB_DEVICE_ID_TOPSEED_CYBERLINK 0x0204
383
386#define USB_VENDOR_ID_TURBOX 0x062a 384#define USB_VENDOR_ID_TURBOX 0x062a
387#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 385#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
388 386
387#define USB_VENDOR_ID_UCLOGIC 0x5543
388#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042
389
389#define USB_VENDOR_ID_VERNIER 0x08f7 390#define USB_VENDOR_ID_VERNIER 0x08f7
390#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 391#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
391#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 392#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 2bae340eafe2..83e07c9f4144 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -26,7 +26,6 @@
26#define LG_RDESC 0x001 26#define LG_RDESC 0x001
27#define LG_BAD_RELATIVE_KEYS 0x002 27#define LG_BAD_RELATIVE_KEYS 0x002
28#define LG_DUPLICATE_USAGES 0x004 28#define LG_DUPLICATE_USAGES 0x004
29#define LG_RESET_LEDS 0x008
30#define LG_EXPANDED_KEYMAP 0x010 29#define LG_EXPANDED_KEYMAP 0x010
31#define LG_IGNORE_DOUBLED_WHEEL 0x020 30#define LG_IGNORE_DOUBLED_WHEEL 0x020
32#define LG_WIRELESS 0x040 31#define LG_WIRELESS 0x040
@@ -248,9 +247,6 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
248 goto err_free; 247 goto err_free;
249 } 248 }
250 249
251 if (quirks & LG_RESET_LEDS)
252 usbhid_set_leds(hdev);
253
254 if (quirks & LG_FF) 250 if (quirks & LG_FF)
255 lgff_init(hdev); 251 lgff_init(hdev);
256 if (quirks & LG_FF2) 252 if (quirks & LG_FF2)
@@ -279,9 +275,6 @@ static const struct hid_device_id lg_devices[] = {
279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI), 275 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI),
280 .driver_data = LG_DUPLICATE_USAGES }, 276 .driver_data = LG_DUPLICATE_USAGES },
281 277
282 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD),
283 .driver_data = LG_RESET_LEDS },
284
285 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD), 278 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD),
286 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP }, 279 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
287 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500), 280 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500),
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
new file mode 100644
index 000000000000..db44fbd7bdf6
--- /dev/null
+++ b/drivers/hid/hid-ntrig.c
@@ -0,0 +1,82 @@
1/*
2 * HID driver for some ntrig "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 * Copyright (c) 2008 Rafi Rubin
11 *
12 */
13
14/*
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option)
18 * any later version.
19 */
20
21#include <linux/device.h>
22#include <linux/hid.h>
23#include <linux/module.h>
24
25#include "hid-ids.h"
26
27#define NTRIG_DUPLICATE_USAGES 0x001
28
29#define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
30 EV_KEY, (c))
31
32static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
33 struct hid_field *field, struct hid_usage *usage,
34 unsigned long **bit, int *max)
35{
36 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_DIGITIZER &&
37 (usage->hid & 0xff) == 0x47) {
38 nt_map_key_clear(BTN_TOOL_DOUBLETAP);
39 return 1;
40 }
41 return 0;
42}
43
44static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi,
45 struct hid_field *field, struct hid_usage *usage,
46 unsigned long **bit, int *max)
47{
48 if (usage->type == EV_KEY || usage->type == EV_REL
49 || usage->type == EV_ABS)
50 clear_bit(usage->code, *bit);
51
52 return 0;
53}
54static const struct hid_device_id ntrig_devices[] = {
55 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN),
56 .driver_data = NTRIG_DUPLICATE_USAGES },
57 { }
58};
59MODULE_DEVICE_TABLE(hid, ntrig_devices);
60
61static struct hid_driver ntrig_driver = {
62 .name = "ntrig",
63 .id_table = ntrig_devices,
64 .input_mapping = ntrig_input_mapping,
65 .input_mapped = ntrig_input_mapped,
66};
67
68static int ntrig_init(void)
69{
70 return hid_register_driver(&ntrig_driver);
71}
72
73static void ntrig_exit(void)
74{
75 hid_unregister_driver(&ntrig_driver);
76}
77
78module_init(ntrig_init);
79module_exit(ntrig_exit);
80MODULE_LICENSE("GPL");
81
82HID_COMPAT_LOAD_DRIVER(ntrig);
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 86e563b8d644..dd5a3979a4de 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -102,7 +102,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
102 } 102 }
103 103
104 ret = sony_set_operational(hdev); 104 ret = sony_set_operational(hdev);
105 if (ret) 105 if (ret < 0)
106 goto err_stop; 106 goto err_stop;
107 107
108 return 0; 108 return 0;
diff --git a/drivers/hid/hid-topseed.c b/drivers/hid/hid-topseed.c
new file mode 100644
index 000000000000..cca64a0564a9
--- /dev/null
+++ b/drivers/hid/hid-topseed.c
@@ -0,0 +1,77 @@
1/*
2 * HID driver for TopSeed Cyberlink remote
3 *
4 * Copyright (c) 2008 Lev Babiev
5 * based on hid-cherry driver
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18
19#include "hid-ids.h"
20
21#define ts_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
22 EV_KEY, (c))
23static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi,
24 struct hid_field *field, struct hid_usage *usage,
25 unsigned long **bit, int *max)
26{
27 if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000)
28 return 0;
29
30 switch (usage->hid & HID_USAGE) {
31 case 0x00d: ts_map_key_clear(KEY_HOME); break;
32 case 0x024: ts_map_key_clear(KEY_MENU); break;
33 case 0x025: ts_map_key_clear(KEY_TV); break;
34 case 0x048: ts_map_key_clear(KEY_RED); break;
35 case 0x047: ts_map_key_clear(KEY_GREEN); break;
36 case 0x049: ts_map_key_clear(KEY_YELLOW); break;
37 case 0x04a: ts_map_key_clear(KEY_BLUE); break;
38 case 0x04b: ts_map_key_clear(KEY_ANGLE); break;
39 case 0x04c: ts_map_key_clear(KEY_LANGUAGE); break;
40 case 0x04d: ts_map_key_clear(KEY_SUBTITLE); break;
41 case 0x031: ts_map_key_clear(KEY_AUDIO); break;
42 case 0x032: ts_map_key_clear(KEY_TEXT); break;
43 case 0x033: ts_map_key_clear(KEY_CHANNEL); break;
44 default:
45 return 0;
46 }
47
48 return 1;
49}
50
51static const struct hid_device_id ts_devices[] = {
52 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
53 { }
54};
55MODULE_DEVICE_TABLE(hid, ts_devices);
56
57static struct hid_driver ts_driver = {
58 .name = "topseed",
59 .id_table = ts_devices,
60 .input_mapping = ts_input_mapping,
61};
62
63static int ts_init(void)
64{
65 return hid_register_driver(&ts_driver);
66}
67
68static void ts_exit(void)
69{
70 hid_unregister_driver(&ts_driver);
71}
72
73module_init(ts_init);
74module_exit(ts_exit);
75MODULE_LICENSE("GPL");
76
77HID_COMPAT_LOAD_DRIVER(topseed);
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 7685ae6808c4..732449628971 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -208,7 +208,7 @@ static int hidraw_release(struct inode * inode, struct file * file)
208 208
209 list_del(&list->node); 209 list_del(&list->node);
210 dev = hidraw_table[minor]; 210 dev = hidraw_table[minor];
211 if (!dev->open--) { 211 if (!--dev->open) {
212 if (list->hidraw->exist) 212 if (list->hidraw->exist)
213 dev->hid->ll_driver->close(dev->hid); 213 dev->hid->ll_driver->close(dev->hid);
214 else 214 else
@@ -265,6 +265,34 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
265 break; 265 break;
266 } 266 }
267 default: 267 default:
268 {
269 struct hid_device *hid = dev->hid;
270 if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ)
271 return -EINVAL;
272
273 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) {
274 int len;
275 if (!hid->name)
276 return 0;
277 len = strlen(hid->name) + 1;
278 if (len > _IOC_SIZE(cmd))
279 len = _IOC_SIZE(cmd);
280 return copy_to_user(user_arg, hid->name, len) ?
281 -EFAULT : len;
282 }
283
284 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) {
285 int len;
286 if (!hid->phys)
287 return 0;
288 len = strlen(hid->phys) + 1;
289 if (len > _IOC_SIZE(cmd))
290 len = _IOC_SIZE(cmd);
291 return copy_to_user(user_arg, hid->phys, len) ?
292 -EFAULT : len;
293 }
294 }
295
268 ret = -ENOTTY; 296 ret = -ENOTTY;
269 } 297 }
270 unlock_kernel(); 298 unlock_kernel();
@@ -329,7 +357,7 @@ int hidraw_connect(struct hid_device *hid)
329 goto out; 357 goto out;
330 } 358 }
331 359
332 dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor), 360 dev->dev = device_create(hidraw_class, &hid->dev, MKDEV(hidraw_major, minor),
333 NULL, "%s%d", "hidraw", minor); 361 NULL, "%s%d", "hidraw", minor);
334 362
335 if (IS_ERR(dev->dev)) { 363 if (IS_ERR(dev->dev)) {
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 5d9aa95fc3ef..4edb3bef94a6 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -45,7 +45,7 @@ config USB_HIDDEV
45 If unsure, say Y. 45 If unsure, say Y.
46 46
47menu "USB HID Boot Protocol drivers" 47menu "USB HID Boot Protocol drivers"
48 depends on USB!=n && USB_HID!=y 48 depends on USB!=n && USB_HID!=y && EMBEDDED
49 49
50config USB_KBD 50config USB_KBD
51 tristate "USB HIDBP Keyboard (simple Boot) support" 51 tristate "USB HIDBP Keyboard (simple Boot) support"
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 606369ea24ca..03cb494af1c5 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -4,7 +4,7 @@
4 * Copyright (c) 1999 Andreas Gal 4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina 7 * Copyright (c) 2006-2008 Jiri Kosina
8 */ 8 */
9 9
10/* 10/*
@@ -641,9 +641,7 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type,
641 unsigned int size; 641 unsigned int size;
642 642
643 list_for_each_entry(report, &hid->report_enum[type].report_list, list) { 643 list_for_each_entry(report, &hid->report_enum[type].report_list, list) {
644 size = ((report->size - 1) >> 3) + 1; 644 size = ((report->size - 1) >> 3) + 1 + hid->report_enum[type].numbered;
645 if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered)
646 size++;
647 if (*max < size) 645 if (*max < size)
648 *max = size; 646 *max = size;
649 } 647 }
@@ -653,13 +651,16 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
653{ 651{
654 struct usbhid_device *usbhid = hid->driver_data; 652 struct usbhid_device *usbhid = hid->driver_data;
655 653
656 if (!(usbhid->inbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->inbuf_dma))) 654 usbhid->inbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
657 return -1; 655 &usbhid->inbuf_dma);
658 if (!(usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->outbuf_dma))) 656 usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
659 return -1; 657 &usbhid->outbuf_dma);
660 if (!(usbhid->cr = usb_buffer_alloc(dev, sizeof(*(usbhid->cr)), GFP_ATOMIC, &usbhid->cr_dma))) 658 usbhid->cr = usb_buffer_alloc(dev, sizeof(*usbhid->cr), GFP_KERNEL,
661 return -1; 659 &usbhid->cr_dma);
662 if (!(usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->ctrlbuf_dma))) 660 usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
661 &usbhid->ctrlbuf_dma);
662 if (!usbhid->inbuf || !usbhid->outbuf || !usbhid->cr ||
663 !usbhid->ctrlbuf)
663 return -1; 664 return -1;
664 665
665 return 0; 666 return 0;
@@ -807,7 +808,7 @@ static int usbhid_start(struct hid_device *hid)
807 int interval; 808 int interval;
808 809
809 endpoint = &interface->endpoint[n].desc; 810 endpoint = &interface->endpoint[n].desc;
810 if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */ 811 if (!usb_endpoint_xfer_int(endpoint))
811 continue; 812 continue;
812 813
813 interval = endpoint->bInterval; 814 interval = endpoint->bInterval;
@@ -876,6 +877,15 @@ static int usbhid_start(struct hid_device *hid)
876 877
877 set_bit(HID_STARTED, &usbhid->iofl); 878 set_bit(HID_STARTED, &usbhid->iofl);
878 879
880 /* Some keyboards don't work until their LEDs have been set.
881 * Since BIOSes do set the LEDs, it must be safe for any device
882 * that supports the keyboard boot protocol.
883 */
884 if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT &&
885 interface->desc.bInterfaceProtocol ==
886 USB_INTERFACE_PROTOCOL_KEYBOARD)
887 usbhid_set_leds(hid);
888
879 return 0; 889 return 0;
880 890
881fail: 891fail:
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 47ebe045f9b5..4391717d2519 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -54,6 +54,7 @@ static const struct hid_blacklist {
54 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 54 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
55 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 55 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
56 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 56 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
57 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT },
57 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 58 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
58 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 59 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
59 60
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 83e851a5ed30..6a98f9f572b0 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -49,6 +49,7 @@
49struct hiddev { 49struct hiddev {
50 int exist; 50 int exist;
51 int open; 51 int open;
52 struct mutex existancelock;
52 wait_queue_head_t wait; 53 wait_queue_head_t wait;
53 struct hid_device *hid; 54 struct hid_device *hid;
54 struct list_head list; 55 struct list_head list;
@@ -63,6 +64,7 @@ struct hiddev_list {
63 struct fasync_struct *fasync; 64 struct fasync_struct *fasync;
64 struct hiddev *hiddev; 65 struct hiddev *hiddev;
65 struct list_head node; 66 struct list_head node;
67 struct mutex thread_lock;
66}; 68};
67 69
68static struct hiddev *hiddev_table[HIDDEV_MINORS]; 70static struct hiddev *hiddev_table[HIDDEV_MINORS];
@@ -264,29 +266,48 @@ static int hiddev_release(struct inode * inode, struct file * file)
264static int hiddev_open(struct inode *inode, struct file *file) 266static int hiddev_open(struct inode *inode, struct file *file)
265{ 267{
266 struct hiddev_list *list; 268 struct hiddev_list *list;
267 unsigned long flags; 269 int res;
268 270
269 int i = iminor(inode) - HIDDEV_MINOR_BASE; 271 int i = iminor(inode) - HIDDEV_MINOR_BASE;
270 272
271 if (i >= HIDDEV_MINORS || !hiddev_table[i]) 273 if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i])
272 return -ENODEV; 274 return -ENODEV;
273 275
274 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) 276 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
275 return -ENOMEM; 277 return -ENOMEM;
278 mutex_init(&list->thread_lock);
276 279
277 list->hiddev = hiddev_table[i]; 280 list->hiddev = hiddev_table[i];
278 281
279 spin_lock_irqsave(&list->hiddev->list_lock, flags);
280 list_add_tail(&list->node, &hiddev_table[i]->list);
281 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
282 282
283 file->private_data = list; 283 file->private_data = list;
284 284
285 if (!list->hiddev->open++) 285 /*
286 if (list->hiddev->exist) 286 * no need for locking because the USB major number
287 usbhid_open(hiddev_table[i]->hid); 287 * is shared which usbcore guards against disconnect
288 */
289 if (list->hiddev->exist) {
290 if (!list->hiddev->open++) {
291 res = usbhid_open(hiddev_table[i]->hid);
292 if (res < 0) {
293 res = -EIO;
294 goto bail;
295 }
296 }
297 } else {
298 res = -ENODEV;
299 goto bail;
300 }
301
302 spin_lock_irq(&list->hiddev->list_lock);
303 list_add_tail(&list->node, &hiddev_table[i]->list);
304 spin_unlock_irq(&list->hiddev->list_lock);
288 305
289 return 0; 306 return 0;
307bail:
308 file->private_data = NULL;
309 kfree(list->hiddev);
310 return res;
290} 311}
291 312
292/* 313/*
@@ -305,7 +326,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
305 DECLARE_WAITQUEUE(wait, current); 326 DECLARE_WAITQUEUE(wait, current);
306 struct hiddev_list *list = file->private_data; 327 struct hiddev_list *list = file->private_data;
307 int event_size; 328 int event_size;
308 int retval = 0; 329 int retval;
309 330
310 event_size = ((list->flags & HIDDEV_FLAG_UREF) != 0) ? 331 event_size = ((list->flags & HIDDEV_FLAG_UREF) != 0) ?
311 sizeof(struct hiddev_usage_ref) : sizeof(struct hiddev_event); 332 sizeof(struct hiddev_usage_ref) : sizeof(struct hiddev_event);
@@ -313,10 +334,14 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
313 if (count < event_size) 334 if (count < event_size)
314 return 0; 335 return 0;
315 336
337 /* lock against other threads */
338 retval = mutex_lock_interruptible(&list->thread_lock);
339 if (retval)
340 return -ERESTARTSYS;
341
316 while (retval == 0) { 342 while (retval == 0) {
317 if (list->head == list->tail) { 343 if (list->head == list->tail) {
318 add_wait_queue(&list->hiddev->wait, &wait); 344 prepare_to_wait(&list->hiddev->wait, &wait, TASK_INTERRUPTIBLE);
319 set_current_state(TASK_INTERRUPTIBLE);
320 345
321 while (list->head == list->tail) { 346 while (list->head == list->tail) {
322 if (file->f_flags & O_NONBLOCK) { 347 if (file->f_flags & O_NONBLOCK) {
@@ -332,35 +357,45 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
332 break; 357 break;
333 } 358 }
334 359
360 /* let O_NONBLOCK tasks run */
361 mutex_unlock(&list->thread_lock);
335 schedule(); 362 schedule();
363 if (mutex_lock_interruptible(&list->thread_lock))
364 return -EINTR;
336 set_current_state(TASK_INTERRUPTIBLE); 365 set_current_state(TASK_INTERRUPTIBLE);
337 } 366 }
367 finish_wait(&list->hiddev->wait, &wait);
338 368
339 set_current_state(TASK_RUNNING);
340 remove_wait_queue(&list->hiddev->wait, &wait);
341 } 369 }
342 370
343 if (retval) 371 if (retval) {
372 mutex_unlock(&list->thread_lock);
344 return retval; 373 return retval;
374 }
345 375
346 376
347 while (list->head != list->tail && 377 while (list->head != list->tail &&
348 retval + event_size <= count) { 378 retval + event_size <= count) {
349 if ((list->flags & HIDDEV_FLAG_UREF) == 0) { 379 if ((list->flags & HIDDEV_FLAG_UREF) == 0) {
350 if (list->buffer[list->tail].field_index != 380 if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE) {
351 HID_FIELD_INDEX_NONE) {
352 struct hiddev_event event; 381 struct hiddev_event event;
382
353 event.hid = list->buffer[list->tail].usage_code; 383 event.hid = list->buffer[list->tail].usage_code;
354 event.value = list->buffer[list->tail].value; 384 event.value = list->buffer[list->tail].value;
355 if (copy_to_user(buffer + retval, &event, sizeof(struct hiddev_event))) 385 if (copy_to_user(buffer + retval, &event, sizeof(struct hiddev_event))) {
386 mutex_unlock(&list->thread_lock);
356 return -EFAULT; 387 return -EFAULT;
388 }
357 retval += sizeof(struct hiddev_event); 389 retval += sizeof(struct hiddev_event);
358 } 390 }
359 } else { 391 } else {
360 if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE || 392 if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE ||
361 (list->flags & HIDDEV_FLAG_REPORT) != 0) { 393 (list->flags & HIDDEV_FLAG_REPORT) != 0) {
362 if (copy_to_user(buffer + retval, list->buffer + list->tail, sizeof(struct hiddev_usage_ref))) 394
395 if (copy_to_user(buffer + retval, list->buffer + list->tail, sizeof(struct hiddev_usage_ref))) {
396 mutex_unlock(&list->thread_lock);
363 return -EFAULT; 397 return -EFAULT;
398 }
364 retval += sizeof(struct hiddev_usage_ref); 399 retval += sizeof(struct hiddev_usage_ref);
365 } 400 }
366 } 401 }
@@ -368,6 +403,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
368 } 403 }
369 404
370 } 405 }
406 mutex_unlock(&list->thread_lock);
371 407
372 return retval; 408 return retval;
373} 409}
@@ -555,7 +591,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
555 struct hid_field *field; 591 struct hid_field *field;
556 struct usbhid_device *usbhid = hid->driver_data; 592 struct usbhid_device *usbhid = hid->driver_data;
557 void __user *user_arg = (void __user *)arg; 593 void __user *user_arg = (void __user *)arg;
558 int i; 594 int i, r;
559 595
560 /* Called without BKL by compat methods so no BKL taken */ 596 /* Called without BKL by compat methods so no BKL taken */
561 597
@@ -619,10 +655,22 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
619 } 655 }
620 656
621 case HIDIOCGSTRING: 657 case HIDIOCGSTRING:
622 return hiddev_ioctl_string(hiddev, cmd, user_arg); 658 mutex_lock(&hiddev->existancelock);
659 if (!hiddev->exist)
660 r = hiddev_ioctl_string(hiddev, cmd, user_arg);
661 else
662 r = -ENODEV;
663 mutex_unlock(&hiddev->existancelock);
664 return r;
623 665
624 case HIDIOCINITREPORT: 666 case HIDIOCINITREPORT:
667 mutex_lock(&hiddev->existancelock);
668 if (!hiddev->exist) {
669 mutex_unlock(&hiddev->existancelock);
670 return -ENODEV;
671 }
625 usbhid_init_reports(hid); 672 usbhid_init_reports(hid);
673 mutex_unlock(&hiddev->existancelock);
626 674
627 return 0; 675 return 0;
628 676
@@ -636,8 +684,12 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
636 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 684 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)
637 return -EINVAL; 685 return -EINVAL;
638 686
639 usbhid_submit_report(hid, report, USB_DIR_IN); 687 mutex_lock(&hiddev->existancelock);
640 usbhid_wait_io(hid); 688 if (hiddev->exist) {
689 usbhid_submit_report(hid, report, USB_DIR_IN);
690 usbhid_wait_io(hid);
691 }
692 mutex_unlock(&hiddev->existancelock);
641 693
642 return 0; 694 return 0;
643 695
@@ -651,8 +703,12 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
651 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 703 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)
652 return -EINVAL; 704 return -EINVAL;
653 705
654 usbhid_submit_report(hid, report, USB_DIR_OUT); 706 mutex_lock(&hiddev->existancelock);
655 usbhid_wait_io(hid); 707 if (hiddev->exist) {
708 usbhid_submit_report(hid, report, USB_DIR_OUT);
709 usbhid_wait_io(hid);
710 }
711 mutex_unlock(&hiddev->existancelock);
656 712
657 return 0; 713 return 0;
658 714
@@ -710,7 +766,13 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
710 case HIDIOCGUSAGES: 766 case HIDIOCGUSAGES:
711 case HIDIOCSUSAGES: 767 case HIDIOCSUSAGES:
712 case HIDIOCGCOLLECTIONINDEX: 768 case HIDIOCGCOLLECTIONINDEX:
713 return hiddev_ioctl_usage(hiddev, cmd, user_arg); 769 mutex_lock(&hiddev->existancelock);
770 if (hiddev->exist)
771 r = hiddev_ioctl_usage(hiddev, cmd, user_arg);
772 else
773 r = -ENODEV;
774 mutex_unlock(&hiddev->existancelock);
775 return r;
714 776
715 case HIDIOCGCOLLECTIONINFO: 777 case HIDIOCGCOLLECTIONINFO:
716 if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) 778 if (copy_from_user(&cinfo, user_arg, sizeof(cinfo)))
@@ -808,23 +870,22 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
808 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL))) 870 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
809 return -1; 871 return -1;
810 872
811 retval = usb_register_dev(usbhid->intf, &hiddev_class);
812 if (retval) {
813 err_hid("Not able to get a minor for this device.");
814 kfree(hiddev);
815 return -1;
816 }
817
818 init_waitqueue_head(&hiddev->wait); 873 init_waitqueue_head(&hiddev->wait);
819 INIT_LIST_HEAD(&hiddev->list); 874 INIT_LIST_HEAD(&hiddev->list);
820 spin_lock_init(&hiddev->list_lock); 875 spin_lock_init(&hiddev->list_lock);
876 mutex_init(&hiddev->existancelock);
821 hiddev->hid = hid; 877 hiddev->hid = hid;
822 hiddev->exist = 1; 878 hiddev->exist = 1;
823 879
824 hid->minor = usbhid->intf->minor; 880 retval = usb_register_dev(usbhid->intf, &hiddev_class);
825 hid->hiddev = hiddev; 881 if (retval) {
826 882 err_hid("Not able to get a minor for this device.");
827 hiddev_table[usbhid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; 883 kfree(hiddev);
884 return -1;
885 } else {
886 hid->minor = usbhid->intf->minor;
887 hiddev_table[usbhid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
888 }
828 889
829 return 0; 890 return 0;
830} 891}
@@ -839,7 +900,9 @@ void hiddev_disconnect(struct hid_device *hid)
839 struct hiddev *hiddev = hid->hiddev; 900 struct hiddev *hiddev = hid->hiddev;
840 struct usbhid_device *usbhid = hid->driver_data; 901 struct usbhid_device *usbhid = hid->driver_data;
841 902
903 mutex_lock(&hiddev->existancelock);
842 hiddev->exist = 0; 904 hiddev->exist = 0;
905 mutex_unlock(&hiddev->existancelock);
843 906
844 hiddev_table[hiddev->hid->minor - HIDDEV_MINOR_BASE] = NULL; 907 hiddev_table[hiddev->hid->minor - HIDDEV_MINOR_BASE] = NULL;
845 usb_deregister_dev(usbhid->intf, &hiddev_class); 908 usb_deregister_dev(usbhid->intf, &hiddev_class);
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 332abcdf9956..9eb30564be9c 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -40,6 +40,16 @@ int usbhid_open(struct hid_device *hid);
40void usbhid_init_reports(struct hid_device *hid); 40void usbhid_init_reports(struct hid_device *hid);
41void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir); 41void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir);
42 42
43/* iofl flags */
44#define HID_CTRL_RUNNING 1
45#define HID_OUT_RUNNING 2
46#define HID_IN_RUNNING 3
47#define HID_RESET_PENDING 4
48#define HID_SUSPENDED 5
49#define HID_CLEAR_HALT 6
50#define HID_DISCONNECTED 7
51#define HID_STARTED 8
52
43/* 53/*
44 * USB-specific HID struct, to be pointed to 54 * USB-specific HID struct, to be pointed to
45 * from struct hid_device->driver_data 55 * from struct hid_device->driver_data
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 608038d64f81..be8ee2cac8bb 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -2,13 +2,16 @@
2 * TI OMAP I2C master mode driver 2 * TI OMAP I2C master mode driver
3 * 3 *
4 * Copyright (C) 2003 MontaVista Software, Inc. 4 * Copyright (C) 2003 MontaVista Software, Inc.
5 * Copyright (C) 2004 Texas Instruments.
6 *
7 * Updated to work with multiple I2C interfaces on 24xx by
8 * Tony Lindgren <tony@atomide.com> and Imre Deak <imre.deak@nokia.com>
9 * Copyright (C) 2005 Nokia Corporation 5 * Copyright (C) 2005 Nokia Corporation
6 * Copyright (C) 2004 - 2007 Texas Instruments.
10 * 7 *
11 * Cleaned up by Juha Yrjölä <juha.yrjola@nokia.com> 8 * Originally written by MontaVista Software, Inc.
9 * Additional contributions by:
10 * Tony Lindgren <tony@atomide.com>
11 * Imre Deak <imre.deak@nokia.com>
12 * Juha Yrjölä <juha.yrjola@solidboot.com>
13 * Syed Khasim <x0khasim@ti.com>
14 * Nishant Menon <nm@ti.com>
12 * 15 *
13 * This program is free software; you can redistribute it and/or modify 16 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 17 * it under the terms of the GNU General Public License as published by
@@ -33,8 +36,14 @@
33#include <linux/completion.h> 36#include <linux/completion.h>
34#include <linux/platform_device.h> 37#include <linux/platform_device.h>
35#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/io.h>
40
41/* I2C controller revisions */
42#define OMAP_I2C_REV_2 0x20
36 43
37#include <asm/io.h> 44/* I2C controller revisions present on specific hardware */
45#define OMAP_I2C_REV_ON_2430 0x36
46#define OMAP_I2C_REV_ON_3430 0x3C
38 47
39/* timeout waiting for the controller to respond */ 48/* timeout waiting for the controller to respond */
40#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) 49#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
@@ -43,6 +52,8 @@
43#define OMAP_I2C_IE_REG 0x04 52#define OMAP_I2C_IE_REG 0x04
44#define OMAP_I2C_STAT_REG 0x08 53#define OMAP_I2C_STAT_REG 0x08
45#define OMAP_I2C_IV_REG 0x0c 54#define OMAP_I2C_IV_REG 0x0c
55/* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */
56#define OMAP_I2C_WE_REG 0x0c
46#define OMAP_I2C_SYSS_REG 0x10 57#define OMAP_I2C_SYSS_REG 0x10
47#define OMAP_I2C_BUF_REG 0x14 58#define OMAP_I2C_BUF_REG 0x14
48#define OMAP_I2C_CNT_REG 0x18 59#define OMAP_I2C_CNT_REG 0x18
@@ -55,8 +66,11 @@
55#define OMAP_I2C_SCLL_REG 0x34 66#define OMAP_I2C_SCLL_REG 0x34
56#define OMAP_I2C_SCLH_REG 0x38 67#define OMAP_I2C_SCLH_REG 0x38
57#define OMAP_I2C_SYSTEST_REG 0x3c 68#define OMAP_I2C_SYSTEST_REG 0x3c
69#define OMAP_I2C_BUFSTAT_REG 0x40
58 70
59/* I2C Interrupt Enable Register (OMAP_I2C_IE): */ 71/* I2C Interrupt Enable Register (OMAP_I2C_IE): */
72#define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */
73#define OMAP_I2C_IE_RDR (1 << 13) /* RX Buffer drain int enable */
60#define OMAP_I2C_IE_XRDY (1 << 4) /* TX data ready int enable */ 74#define OMAP_I2C_IE_XRDY (1 << 4) /* TX data ready int enable */
61#define OMAP_I2C_IE_RRDY (1 << 3) /* RX data ready int enable */ 75#define OMAP_I2C_IE_RRDY (1 << 3) /* RX data ready int enable */
62#define OMAP_I2C_IE_ARDY (1 << 2) /* Access ready int enable */ 76#define OMAP_I2C_IE_ARDY (1 << 2) /* Access ready int enable */
@@ -64,7 +78,8 @@
64#define OMAP_I2C_IE_AL (1 << 0) /* Arbitration lost int ena */ 78#define OMAP_I2C_IE_AL (1 << 0) /* Arbitration lost int ena */
65 79
66/* I2C Status Register (OMAP_I2C_STAT): */ 80/* I2C Status Register (OMAP_I2C_STAT): */
67#define OMAP_I2C_STAT_SBD (1 << 15) /* Single byte data */ 81#define OMAP_I2C_STAT_XDR (1 << 14) /* TX Buffer draining */
82#define OMAP_I2C_STAT_RDR (1 << 13) /* RX Buffer draining */
68#define OMAP_I2C_STAT_BB (1 << 12) /* Bus busy */ 83#define OMAP_I2C_STAT_BB (1 << 12) /* Bus busy */
69#define OMAP_I2C_STAT_ROVR (1 << 11) /* Receive overrun */ 84#define OMAP_I2C_STAT_ROVR (1 << 11) /* Receive overrun */
70#define OMAP_I2C_STAT_XUDF (1 << 10) /* Transmit underflow */ 85#define OMAP_I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
@@ -76,13 +91,34 @@
76#define OMAP_I2C_STAT_NACK (1 << 1) /* No ack interrupt enable */ 91#define OMAP_I2C_STAT_NACK (1 << 1) /* No ack interrupt enable */
77#define OMAP_I2C_STAT_AL (1 << 0) /* Arbitration lost int ena */ 92#define OMAP_I2C_STAT_AL (1 << 0) /* Arbitration lost int ena */
78 93
94/* I2C WE wakeup enable register */
95#define OMAP_I2C_WE_XDR_WE (1 << 14) /* TX drain wakup */
96#define OMAP_I2C_WE_RDR_WE (1 << 13) /* RX drain wakeup */
97#define OMAP_I2C_WE_AAS_WE (1 << 9) /* Address as slave wakeup*/
98#define OMAP_I2C_WE_BF_WE (1 << 8) /* Bus free wakeup */
99#define OMAP_I2C_WE_STC_WE (1 << 6) /* Start condition wakeup */
100#define OMAP_I2C_WE_GC_WE (1 << 5) /* General call wakeup */
101#define OMAP_I2C_WE_DRDY_WE (1 << 3) /* TX/RX data ready wakeup */
102#define OMAP_I2C_WE_ARDY_WE (1 << 2) /* Reg access ready wakeup */
103#define OMAP_I2C_WE_NACK_WE (1 << 1) /* No acknowledgment wakeup */
104#define OMAP_I2C_WE_AL_WE (1 << 0) /* Arbitration lost wakeup */
105
106#define OMAP_I2C_WE_ALL (OMAP_I2C_WE_XDR_WE | OMAP_I2C_WE_RDR_WE | \
107 OMAP_I2C_WE_AAS_WE | OMAP_I2C_WE_BF_WE | \
108 OMAP_I2C_WE_STC_WE | OMAP_I2C_WE_GC_WE | \
109 OMAP_I2C_WE_DRDY_WE | OMAP_I2C_WE_ARDY_WE | \
110 OMAP_I2C_WE_NACK_WE | OMAP_I2C_WE_AL_WE)
111
79/* I2C Buffer Configuration Register (OMAP_I2C_BUF): */ 112/* I2C Buffer Configuration Register (OMAP_I2C_BUF): */
80#define OMAP_I2C_BUF_RDMA_EN (1 << 15) /* RX DMA channel enable */ 113#define OMAP_I2C_BUF_RDMA_EN (1 << 15) /* RX DMA channel enable */
114#define OMAP_I2C_BUF_RXFIF_CLR (1 << 14) /* RX FIFO Clear */
81#define OMAP_I2C_BUF_XDMA_EN (1 << 7) /* TX DMA channel enable */ 115#define OMAP_I2C_BUF_XDMA_EN (1 << 7) /* TX DMA channel enable */
116#define OMAP_I2C_BUF_TXFIF_CLR (1 << 6) /* TX FIFO Clear */
82 117
83/* I2C Configuration Register (OMAP_I2C_CON): */ 118/* I2C Configuration Register (OMAP_I2C_CON): */
84#define OMAP_I2C_CON_EN (1 << 15) /* I2C module enable */ 119#define OMAP_I2C_CON_EN (1 << 15) /* I2C module enable */
85#define OMAP_I2C_CON_BE (1 << 14) /* Big endian mode */ 120#define OMAP_I2C_CON_BE (1 << 14) /* Big endian mode */
121#define OMAP_I2C_CON_OPMODE_HS (1 << 12) /* High Speed support */
86#define OMAP_I2C_CON_STB (1 << 11) /* Start byte mode (master) */ 122#define OMAP_I2C_CON_STB (1 << 11) /* Start byte mode (master) */
87#define OMAP_I2C_CON_MST (1 << 10) /* Master/slave mode */ 123#define OMAP_I2C_CON_MST (1 << 10) /* Master/slave mode */
88#define OMAP_I2C_CON_TRX (1 << 9) /* TX/RX mode (master only) */ 124#define OMAP_I2C_CON_TRX (1 << 9) /* TX/RX mode (master only) */
@@ -91,6 +127,10 @@
91#define OMAP_I2C_CON_STP (1 << 1) /* Stop cond (master only) */ 127#define OMAP_I2C_CON_STP (1 << 1) /* Stop cond (master only) */
92#define OMAP_I2C_CON_STT (1 << 0) /* Start condition (master) */ 128#define OMAP_I2C_CON_STT (1 << 0) /* Start condition (master) */
93 129
130/* I2C SCL time value when Master */
131#define OMAP_I2C_SCLL_HSSCLL 8
132#define OMAP_I2C_SCLH_HSSCLH 8
133
94/* I2C System Test Register (OMAP_I2C_SYSTEST): */ 134/* I2C System Test Register (OMAP_I2C_SYSTEST): */
95#ifdef DEBUG 135#ifdef DEBUG
96#define OMAP_I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */ 136#define OMAP_I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */
@@ -103,17 +143,19 @@
103#define OMAP_I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive out */ 143#define OMAP_I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive out */
104#endif 144#endif
105 145
106/* I2C System Status register (OMAP_I2C_SYSS): */ 146/* OCP_SYSSTATUS bit definitions */
107#define OMAP_I2C_SYSS_RDONE (1 << 0) /* Reset Done */ 147#define SYSS_RESETDONE_MASK (1 << 0)
148
149/* OCP_SYSCONFIG bit definitions */
150#define SYSC_CLOCKACTIVITY_MASK (0x3 << 8)
151#define SYSC_SIDLEMODE_MASK (0x3 << 3)
152#define SYSC_ENAWAKEUP_MASK (1 << 2)
153#define SYSC_SOFTRESET_MASK (1 << 1)
154#define SYSC_AUTOIDLE_MASK (1 << 0)
108 155
109/* I2C System Configuration Register (OMAP_I2C_SYSC): */ 156#define SYSC_IDLEMODE_SMART 0x2
110#define OMAP_I2C_SYSC_SRST (1 << 1) /* Soft Reset */ 157#define SYSC_CLOCKACTIVITY_FCLK 0x2
111 158
112/* REVISIT: Use platform_data instead of module parameters */
113/* Fast Mode = 400 kHz, Standard = 100 kHz */
114static int clock = 100; /* Default: 100 kHz */
115module_param(clock, int, 0);
116MODULE_PARM_DESC(clock, "Set I2C clock in kHz: 400=fast mode (default == 100)");
117 159
118struct omap_i2c_dev { 160struct omap_i2c_dev {
119 struct device *dev; 161 struct device *dev;
@@ -123,11 +165,17 @@ struct omap_i2c_dev {
123 struct clk *fclk; /* Functional clock */ 165 struct clk *fclk; /* Functional clock */
124 struct completion cmd_complete; 166 struct completion cmd_complete;
125 struct resource *ioarea; 167 struct resource *ioarea;
168 u32 speed; /* Speed of bus in Khz */
126 u16 cmd_err; 169 u16 cmd_err;
127 u8 *buf; 170 u8 *buf;
128 size_t buf_len; 171 size_t buf_len;
129 struct i2c_adapter adapter; 172 struct i2c_adapter adapter;
130 unsigned rev1:1; 173 u8 fifo_size; /* use as flag and value
174 * fifo_size==0 implies no fifo
175 * if set, should be trsh+1
176 */
177 u8 rev;
178 unsigned b_hw:1; /* bad h/w fixes */
131 unsigned idle:1; 179 unsigned idle:1;
132 u16 iestate; /* Saved interrupt register */ 180 u16 iestate; /* Saved interrupt register */
133}; 181};
@@ -143,9 +191,9 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
143 return __raw_readw(i2c_dev->base + reg); 191 return __raw_readw(i2c_dev->base + reg);
144} 192}
145 193
146static int omap_i2c_get_clocks(struct omap_i2c_dev *dev) 194static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev)
147{ 195{
148 if (cpu_is_omap16xx() || cpu_is_omap24xx()) { 196 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
149 dev->iclk = clk_get(dev->dev, "i2c_ick"); 197 dev->iclk = clk_get(dev->dev, "i2c_ick");
150 if (IS_ERR(dev->iclk)) { 198 if (IS_ERR(dev->iclk)) {
151 dev->iclk = NULL; 199 dev->iclk = NULL;
@@ -178,25 +226,33 @@ static void omap_i2c_put_clocks(struct omap_i2c_dev *dev)
178 226
179static void omap_i2c_unidle(struct omap_i2c_dev *dev) 227static void omap_i2c_unidle(struct omap_i2c_dev *dev)
180{ 228{
229 WARN_ON(!dev->idle);
230
181 if (dev->iclk != NULL) 231 if (dev->iclk != NULL)
182 clk_enable(dev->iclk); 232 clk_enable(dev->iclk);
183 clk_enable(dev->fclk); 233 clk_enable(dev->fclk);
234 dev->idle = 0;
184 if (dev->iestate) 235 if (dev->iestate)
185 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate); 236 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
186 dev->idle = 0;
187} 237}
188 238
189static void omap_i2c_idle(struct omap_i2c_dev *dev) 239static void omap_i2c_idle(struct omap_i2c_dev *dev)
190{ 240{
191 u16 iv; 241 u16 iv;
192 242
193 dev->idle = 1; 243 WARN_ON(dev->idle);
244
194 dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); 245 dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
195 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); 246 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0);
196 if (dev->rev1) 247 if (dev->rev < OMAP_I2C_REV_2) {
197 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ 248 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */
198 else 249 } else {
199 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate); 250 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate);
251
252 /* Flush posted write before the dev->idle store occurs */
253 omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
254 }
255 dev->idle = 1;
200 clk_disable(dev->fclk); 256 clk_disable(dev->fclk);
201 if (dev->iclk != NULL) 257 if (dev->iclk != NULL)
202 clk_disable(dev->iclk); 258 clk_disable(dev->iclk);
@@ -204,18 +260,20 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
204 260
205static int omap_i2c_init(struct omap_i2c_dev *dev) 261static int omap_i2c_init(struct omap_i2c_dev *dev)
206{ 262{
207 u16 psc = 0; 263 u16 psc = 0, scll = 0, sclh = 0;
264 u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
208 unsigned long fclk_rate = 12000000; 265 unsigned long fclk_rate = 12000000;
209 unsigned long timeout; 266 unsigned long timeout;
267 unsigned long internal_clk = 0;
210 268
211 if (!dev->rev1) { 269 if (dev->rev >= OMAP_I2C_REV_2) {
212 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, OMAP_I2C_SYSC_SRST); 270 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK);
213 /* For some reason we need to set the EN bit before the 271 /* For some reason we need to set the EN bit before the
214 * reset done bit gets set. */ 272 * reset done bit gets set. */
215 timeout = jiffies + OMAP_I2C_TIMEOUT; 273 timeout = jiffies + OMAP_I2C_TIMEOUT;
216 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 274 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
217 while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) & 275 while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
218 OMAP_I2C_SYSS_RDONE)) { 276 SYSS_RESETDONE_MASK)) {
219 if (time_after(jiffies, timeout)) { 277 if (time_after(jiffies, timeout)) {
220 dev_warn(dev->dev, "timeout waiting " 278 dev_warn(dev->dev, "timeout waiting "
221 "for controller reset\n"); 279 "for controller reset\n");
@@ -223,6 +281,33 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
223 } 281 }
224 msleep(1); 282 msleep(1);
225 } 283 }
284
285 /* SYSC register is cleared by the reset; rewrite it */
286 if (dev->rev == OMAP_I2C_REV_ON_2430) {
287
288 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
289 SYSC_AUTOIDLE_MASK);
290
291 } else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
292 u32 v;
293
294 v = SYSC_AUTOIDLE_MASK;
295 v |= SYSC_ENAWAKEUP_MASK;
296 v |= (SYSC_IDLEMODE_SMART <<
297 __ffs(SYSC_SIDLEMODE_MASK));
298 v |= (SYSC_CLOCKACTIVITY_FCLK <<
299 __ffs(SYSC_CLOCKACTIVITY_MASK));
300
301 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, v);
302 /*
303 * Enabling all wakup sources to stop I2C freezing on
304 * WFI instruction.
305 * REVISIT: Some wkup sources might not be needed.
306 */
307 omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
308 OMAP_I2C_WE_ALL);
309
310 }
226 } 311 }
227 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 312 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
228 313
@@ -249,27 +334,65 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
249 psc = fclk_rate / 12000000; 334 psc = fclk_rate / 12000000;
250 } 335 }
251 336
337 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
338
339 /* HSI2C controller internal clk rate should be 19.2 Mhz */
340 internal_clk = 19200;
341 fclk_rate = clk_get_rate(dev->fclk) / 1000;
342
343 /* Compute prescaler divisor */
344 psc = fclk_rate / internal_clk;
345 psc = psc - 1;
346
347 /* If configured for High Speed */
348 if (dev->speed > 400) {
349 /* For first phase of HS mode */
350 fsscll = internal_clk / (400 * 2) - 6;
351 fssclh = internal_clk / (400 * 2) - 6;
352
353 /* For second phase of HS mode */
354 hsscll = fclk_rate / (dev->speed * 2) - 6;
355 hssclh = fclk_rate / (dev->speed * 2) - 6;
356 } else {
357 /* To handle F/S modes */
358 fsscll = internal_clk / (dev->speed * 2) - 6;
359 fssclh = internal_clk / (dev->speed * 2) - 6;
360 }
361 scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
362 sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
363 } else {
364 /* Program desired operating rate */
365 fclk_rate /= (psc + 1) * 1000;
366 if (psc > 2)
367 psc = 2;
368 scll = fclk_rate / (dev->speed * 2) - 7 + psc;
369 sclh = fclk_rate / (dev->speed * 2) - 7 + psc;
370 }
371
252 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */ 372 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */
253 omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, psc); 373 omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, psc);
254 374
255 /* Program desired operating rate */ 375 /* SCL low and high time values */
256 fclk_rate /= (psc + 1) * 1000; 376 omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, scll);
257 if (psc > 2) 377 omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, sclh);
258 psc = 2;
259 378
260 omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, 379 if (dev->fifo_size)
261 fclk_rate / (clock * 2) - 7 + psc); 380 /* Note: setup required fifo size - 1 */
262 omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, 381 omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG,
263 fclk_rate / (clock * 2) - 7 + psc); 382 (dev->fifo_size - 1) << 8 | /* RTRSH */
383 OMAP_I2C_BUF_RXFIF_CLR |
384 (dev->fifo_size - 1) | /* XTRSH */
385 OMAP_I2C_BUF_TXFIF_CLR);
264 386
265 /* Take the I2C module out of reset: */ 387 /* Take the I2C module out of reset: */
266 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 388 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
267 389
268 /* Enable interrupts */ 390 /* Enable interrupts */
269 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 391 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG,
270 (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | 392 (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY |
271 OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | 393 OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK |
272 OMAP_I2C_IE_AL)); 394 OMAP_I2C_IE_AL) | ((dev->fifo_size) ?
395 (OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0));
273 return 0; 396 return 0;
274} 397}
275 398
@@ -316,20 +439,59 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
316 439
317 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); 440 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len);
318 441
442 /* Clear the FIFO Buffers */
443 w = omap_i2c_read_reg(dev, OMAP_I2C_BUF_REG);
444 w |= OMAP_I2C_BUF_RXFIF_CLR | OMAP_I2C_BUF_TXFIF_CLR;
445 omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, w);
446
319 init_completion(&dev->cmd_complete); 447 init_completion(&dev->cmd_complete);
320 dev->cmd_err = 0; 448 dev->cmd_err = 0;
321 449
322 w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT; 450 w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT;
451
452 /* High speed configuration */
453 if (dev->speed > 400)
454 w |= OMAP_I2C_CON_OPMODE_HS;
455
323 if (msg->flags & I2C_M_TEN) 456 if (msg->flags & I2C_M_TEN)
324 w |= OMAP_I2C_CON_XA; 457 w |= OMAP_I2C_CON_XA;
325 if (!(msg->flags & I2C_M_RD)) 458 if (!(msg->flags & I2C_M_RD))
326 w |= OMAP_I2C_CON_TRX; 459 w |= OMAP_I2C_CON_TRX;
327 if (stop) 460
461 if (!dev->b_hw && stop)
328 w |= OMAP_I2C_CON_STP; 462 w |= OMAP_I2C_CON_STP;
463
329 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); 464 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
330 465
331 r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, 466 /*
332 OMAP_I2C_TIMEOUT); 467 * Don't write stt and stp together on some hardware.
468 */
469 if (dev->b_hw && stop) {
470 unsigned long delay = jiffies + OMAP_I2C_TIMEOUT;
471 u16 con = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
472 while (con & OMAP_I2C_CON_STT) {
473 con = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
474
475 /* Let the user know if i2c is in a bad state */
476 if (time_after(jiffies, delay)) {
477 dev_err(dev->dev, "controller timed out "
478 "waiting for start condition to finish\n");
479 return -ETIMEDOUT;
480 }
481 cpu_relax();
482 }
483
484 w |= OMAP_I2C_CON_STP;
485 w &= ~OMAP_I2C_CON_STT;
486 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
487 }
488
489 /*
490 * REVISIT: We should abort the transfer on signals, but the bus goes
491 * into arbitration and we're currently unable to recover from it.
492 */
493 r = wait_for_completion_timeout(&dev->cmd_complete,
494 OMAP_I2C_TIMEOUT);
333 dev->buf_len = 0; 495 dev->buf_len = 0;
334 if (r < 0) 496 if (r < 0)
335 return r; 497 return r;
@@ -376,7 +538,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
376 538
377 omap_i2c_unidle(dev); 539 omap_i2c_unidle(dev);
378 540
379 if ((r = omap_i2c_wait_for_bb(dev)) < 0) 541 r = omap_i2c_wait_for_bb(dev);
542 if (r < 0)
380 goto out; 543 goto out;
381 544
382 for (i = 0; i < num; i++) { 545 for (i = 0; i < num; i++) {
@@ -411,6 +574,9 @@ omap_i2c_ack_stat(struct omap_i2c_dev *dev, u16 stat)
411 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); 574 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
412} 575}
413 576
577/* rev1 devices are apparently only on some 15xx */
578#ifdef CONFIG_ARCH_OMAP15XX
579
414static irqreturn_t 580static irqreturn_t
415omap_i2c_rev1_isr(int this_irq, void *dev_id) 581omap_i2c_rev1_isr(int this_irq, void *dev_id)
416{ 582{
@@ -465,6 +631,9 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id)
465 631
466 return IRQ_HANDLED; 632 return IRQ_HANDLED;
467} 633}
634#else
635#define omap_i2c_rev1_isr NULL
636#endif
468 637
469static irqreturn_t 638static irqreturn_t
470omap_i2c_isr(int this_irq, void *dev_id) 639omap_i2c_isr(int this_irq, void *dev_id)
@@ -472,7 +641,7 @@ omap_i2c_isr(int this_irq, void *dev_id)
472 struct omap_i2c_dev *dev = dev_id; 641 struct omap_i2c_dev *dev = dev_id;
473 u16 bits; 642 u16 bits;
474 u16 stat, w; 643 u16 stat, w;
475 int count = 0; 644 int err, count = 0;
476 645
477 if (dev->idle) 646 if (dev->idle)
478 return IRQ_NONE; 647 return IRQ_NONE;
@@ -487,39 +656,96 @@ omap_i2c_isr(int this_irq, void *dev_id)
487 656
488 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); 657 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
489 658
490 if (stat & OMAP_I2C_STAT_ARDY) { 659 err = 0;
491 omap_i2c_complete_cmd(dev, 0); 660 if (stat & OMAP_I2C_STAT_NACK) {
492 continue; 661 err |= OMAP_I2C_STAT_NACK;
662 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
663 OMAP_I2C_CON_STP);
493 } 664 }
494 if (stat & OMAP_I2C_STAT_RRDY) { 665 if (stat & OMAP_I2C_STAT_AL) {
495 w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG); 666 dev_err(dev->dev, "Arbitration lost\n");
496 if (dev->buf_len) { 667 err |= OMAP_I2C_STAT_AL;
497 *dev->buf++ = w; 668 }
498 dev->buf_len--; 669 if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
670 OMAP_I2C_STAT_AL))
671 omap_i2c_complete_cmd(dev, err);
672 if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
673 u8 num_bytes = 1;
674 if (dev->fifo_size) {
675 if (stat & OMAP_I2C_STAT_RRDY)
676 num_bytes = dev->fifo_size;
677 else
678 num_bytes = omap_i2c_read_reg(dev,
679 OMAP_I2C_BUFSTAT_REG);
680 }
681 while (num_bytes) {
682 num_bytes--;
683 w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
499 if (dev->buf_len) { 684 if (dev->buf_len) {
500 *dev->buf++ = w >> 8; 685 *dev->buf++ = w;
501 dev->buf_len--; 686 dev->buf_len--;
687 /* Data reg from 2430 is 8 bit wide */
688 if (!cpu_is_omap2430() &&
689 !cpu_is_omap34xx()) {
690 if (dev->buf_len) {
691 *dev->buf++ = w >> 8;
692 dev->buf_len--;
693 }
694 }
695 } else {
696 if (stat & OMAP_I2C_STAT_RRDY)
697 dev_err(dev->dev,
698 "RRDY IRQ while no data"
699 " requested\n");
700 if (stat & OMAP_I2C_STAT_RDR)
701 dev_err(dev->dev,
702 "RDR IRQ while no data"
703 " requested\n");
704 break;
502 } 705 }
503 } else 706 }
504 dev_err(dev->dev, "RRDY IRQ while no data " 707 omap_i2c_ack_stat(dev,
505 "requested\n"); 708 stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
506 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RRDY);
507 continue; 709 continue;
508 } 710 }
509 if (stat & OMAP_I2C_STAT_XRDY) { 711 if (stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)) {
510 w = 0; 712 u8 num_bytes = 1;
511 if (dev->buf_len) { 713 if (dev->fifo_size) {
512 w = *dev->buf++; 714 if (stat & OMAP_I2C_STAT_XRDY)
513 dev->buf_len--; 715 num_bytes = dev->fifo_size;
716 else
717 num_bytes = omap_i2c_read_reg(dev,
718 OMAP_I2C_BUFSTAT_REG);
719 }
720 while (num_bytes) {
721 num_bytes--;
722 w = 0;
514 if (dev->buf_len) { 723 if (dev->buf_len) {
515 w |= *dev->buf++ << 8; 724 w = *dev->buf++;
516 dev->buf_len--; 725 dev->buf_len--;
726 /* Data reg from 2430 is 8 bit wide */
727 if (!cpu_is_omap2430() &&
728 !cpu_is_omap34xx()) {
729 if (dev->buf_len) {
730 w |= *dev->buf++ << 8;
731 dev->buf_len--;
732 }
733 }
734 } else {
735 if (stat & OMAP_I2C_STAT_XRDY)
736 dev_err(dev->dev,
737 "XRDY IRQ while no "
738 "data to send\n");
739 if (stat & OMAP_I2C_STAT_XDR)
740 dev_err(dev->dev,
741 "XDR IRQ while no "
742 "data to send\n");
743 break;
517 } 744 }
518 } else 745 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
519 dev_err(dev->dev, "XRDY IRQ while no " 746 }
520 "data to send\n"); 747 omap_i2c_ack_stat(dev,
521 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); 748 stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
522 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY);
523 continue; 749 continue;
524 } 750 }
525 if (stat & OMAP_I2C_STAT_ROVR) { 751 if (stat & OMAP_I2C_STAT_ROVR) {
@@ -527,18 +753,9 @@ omap_i2c_isr(int this_irq, void *dev_id)
527 dev->cmd_err |= OMAP_I2C_STAT_ROVR; 753 dev->cmd_err |= OMAP_I2C_STAT_ROVR;
528 } 754 }
529 if (stat & OMAP_I2C_STAT_XUDF) { 755 if (stat & OMAP_I2C_STAT_XUDF) {
530 dev_err(dev->dev, "Transmit overflow\n"); 756 dev_err(dev->dev, "Transmit underflow\n");
531 dev->cmd_err |= OMAP_I2C_STAT_XUDF; 757 dev->cmd_err |= OMAP_I2C_STAT_XUDF;
532 } 758 }
533 if (stat & OMAP_I2C_STAT_NACK) {
534 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_NACK);
535 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
536 OMAP_I2C_CON_STP);
537 }
538 if (stat & OMAP_I2C_STAT_AL) {
539 dev_err(dev->dev, "Arbitration lost\n");
540 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_AL);
541 }
542 } 759 }
543 760
544 return count ? IRQ_HANDLED : IRQ_NONE; 761 return count ? IRQ_HANDLED : IRQ_NONE;
@@ -549,13 +766,15 @@ static const struct i2c_algorithm omap_i2c_algo = {
549 .functionality = omap_i2c_func, 766 .functionality = omap_i2c_func,
550}; 767};
551 768
552static int 769static int __init
553omap_i2c_probe(struct platform_device *pdev) 770omap_i2c_probe(struct platform_device *pdev)
554{ 771{
555 struct omap_i2c_dev *dev; 772 struct omap_i2c_dev *dev;
556 struct i2c_adapter *adap; 773 struct i2c_adapter *adap;
557 struct resource *mem, *irq, *ioarea; 774 struct resource *mem, *irq, *ioarea;
775 irq_handler_t isr;
558 int r; 776 int r;
777 u32 speed = 0;
559 778
560 /* NOTE: driver uses the static register mapping */ 779 /* NOTE: driver uses the static register mapping */
561 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 780 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -576,17 +795,19 @@ omap_i2c_probe(struct platform_device *pdev)
576 return -EBUSY; 795 return -EBUSY;
577 } 796 }
578 797
579 if (clock > 200)
580 clock = 400; /* Fast mode */
581 else
582 clock = 100; /* Standard mode */
583
584 dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL); 798 dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL);
585 if (!dev) { 799 if (!dev) {
586 r = -ENOMEM; 800 r = -ENOMEM;
587 goto err_release_region; 801 goto err_release_region;
588 } 802 }
589 803
804 if (pdev->dev.platform_data != NULL)
805 speed = *(u32 *)pdev->dev.platform_data;
806 else
807 speed = 100; /* Defualt speed */
808
809 dev->speed = speed;
810 dev->idle = 1;
590 dev->dev = &pdev->dev; 811 dev->dev = &pdev->dev;
591 dev->irq = irq->start; 812 dev->irq = irq->start;
592 dev->base = ioremap(mem->start, mem->end - mem->start + 1); 813 dev->base = ioremap(mem->start, mem->end - mem->start + 1);
@@ -602,22 +823,39 @@ omap_i2c_probe(struct platform_device *pdev)
602 823
603 omap_i2c_unidle(dev); 824 omap_i2c_unidle(dev);
604 825
605 if (cpu_is_omap15xx()) 826 dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff;
606 dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20; 827
828 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
829 u16 s;
830
831 /* Set up the fifo size - Get total size */
832 s = (omap_i2c_read_reg(dev, OMAP_I2C_BUFSTAT_REG) >> 14) & 0x3;
833 dev->fifo_size = 0x8 << s;
834
835 /*
836 * Set up notification threshold as half the total available
837 * size. This is to ensure that we can handle the status on int
838 * call back latencies.
839 */
840 dev->fifo_size = (dev->fifo_size / 2);
841 dev->b_hw = 1; /* Enable hardware fixes */
842 }
607 843
608 /* reset ASAP, clearing any IRQs */ 844 /* reset ASAP, clearing any IRQs */
609 omap_i2c_init(dev); 845 omap_i2c_init(dev);
610 846
611 r = request_irq(dev->irq, dev->rev1 ? omap_i2c_rev1_isr : omap_i2c_isr, 847 isr = (dev->rev < OMAP_I2C_REV_2) ? omap_i2c_rev1_isr : omap_i2c_isr;
612 0, pdev->name, dev); 848 r = request_irq(dev->irq, isr, 0, pdev->name, dev);
613 849
614 if (r) { 850 if (r) {
615 dev_err(dev->dev, "failure requesting irq %i\n", dev->irq); 851 dev_err(dev->dev, "failure requesting irq %i\n", dev->irq);
616 goto err_unuse_clocks; 852 goto err_unuse_clocks;
617 } 853 }
618 r = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; 854
619 dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n", 855 dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n",
620 pdev->id, r >> 4, r & 0xf, clock); 856 pdev->id, dev->rev >> 4, dev->rev & 0xf, dev->speed);
857
858 omap_i2c_idle(dev);
621 859
622 adap = &dev->adapter; 860 adap = &dev->adapter;
623 i2c_set_adapdata(adap, dev); 861 i2c_set_adapdata(adap, dev);
@@ -635,8 +873,6 @@ omap_i2c_probe(struct platform_device *pdev)
635 goto err_free_irq; 873 goto err_free_irq;
636 } 874 }
637 875
638 omap_i2c_idle(dev);
639
640 return 0; 876 return 0;
641 877
642err_free_irq: 878err_free_irq:
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index c39079f9c73f..f69f91ffb469 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -35,11 +35,9 @@
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/cpufreq.h> 36#include <linux/cpufreq.h>
37 37
38#include <mach/hardware.h>
39#include <asm/irq.h> 38#include <asm/irq.h>
40#include <asm/io.h> 39#include <asm/io.h>
41 40
42#include <mach/regs-gpio.h>
43#include <plat/regs-iic.h> 41#include <plat/regs-iic.h>
44#include <plat/iic.h> 42#include <plat/iic.h>
45 43
@@ -64,6 +62,7 @@ struct s3c24xx_i2c {
64 unsigned int msg_ptr; 62 unsigned int msg_ptr;
65 63
66 unsigned int tx_setup; 64 unsigned int tx_setup;
65 unsigned int irq;
67 66
68 enum s3c24xx_i2c_state state; 67 enum s3c24xx_i2c_state state;
69 unsigned long clkrate; 68 unsigned long clkrate;
@@ -71,7 +70,6 @@ struct s3c24xx_i2c {
71 void __iomem *regs; 70 void __iomem *regs;
72 struct clk *clk; 71 struct clk *clk;
73 struct device *dev; 72 struct device *dev;
74 struct resource *irq;
75 struct resource *ioarea; 73 struct resource *ioarea;
76 struct i2c_adapter adap; 74 struct i2c_adapter adap;
77 75
@@ -80,16 +78,7 @@ struct s3c24xx_i2c {
80#endif 78#endif
81}; 79};
82 80
83/* default platform data to use if not supplied in the platform_device 81/* default platform data removed, dev should always carry data. */
84*/
85
86static struct s3c2410_platform_i2c s3c24xx_i2c_default_platform = {
87 .flags = 0,
88 .slave_addr = 0x10,
89 .bus_freq = 100*1000,
90 .max_freq = 400*1000,
91 .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
92};
93 82
94/* s3c24xx_i2c_is2440() 83/* s3c24xx_i2c_is2440()
95 * 84 *
@@ -103,21 +92,6 @@ static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
103 return !strcmp(pdev->name, "s3c2440-i2c"); 92 return !strcmp(pdev->name, "s3c2440-i2c");
104} 93}
105 94
106
107/* s3c24xx_i2c_get_platformdata
108 *
109 * get the platform data associated with the given device, or return
110 * the default if there is none
111*/
112
113static inline struct s3c2410_platform_i2c *s3c24xx_i2c_get_platformdata(struct device *dev)
114{
115 if (dev->platform_data != NULL)
116 return (struct s3c2410_platform_i2c *)dev->platform_data;
117
118 return &s3c24xx_i2c_default_platform;
119}
120
121/* s3c24xx_i2c_master_complete 95/* s3c24xx_i2c_master_complete
122 * 96 *
123 * complete the message and wake up the caller, using the given return code, 97 * complete the message and wake up the caller, using the given return code,
@@ -130,7 +104,7 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
130 104
131 i2c->msg_ptr = 0; 105 i2c->msg_ptr = 0;
132 i2c->msg = NULL; 106 i2c->msg = NULL;
133 i2c->msg_idx ++; 107 i2c->msg_idx++;
134 i2c->msg_num = 0; 108 i2c->msg_num = 0;
135 if (ret) 109 if (ret)
136 i2c->msg_idx = ret; 110 i2c->msg_idx = ret;
@@ -141,19 +115,17 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
141static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c) 115static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c)
142{ 116{
143 unsigned long tmp; 117 unsigned long tmp;
144 118
145 tmp = readl(i2c->regs + S3C2410_IICCON); 119 tmp = readl(i2c->regs + S3C2410_IICCON);
146 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); 120 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
147
148} 121}
149 122
150static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c) 123static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
151{ 124{
152 unsigned long tmp; 125 unsigned long tmp;
153 126
154 tmp = readl(i2c->regs + S3C2410_IICCON); 127 tmp = readl(i2c->regs + S3C2410_IICCON);
155 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); 128 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
156
157} 129}
158 130
159/* irq enable/disable functions */ 131/* irq enable/disable functions */
@@ -161,7 +133,7 @@ static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
161static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c) 133static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
162{ 134{
163 unsigned long tmp; 135 unsigned long tmp;
164 136
165 tmp = readl(i2c->regs + S3C2410_IICCON); 137 tmp = readl(i2c->regs + S3C2410_IICCON);
166 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); 138 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
167} 139}
@@ -169,7 +141,7 @@ static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
169static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c) 141static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
170{ 142{
171 unsigned long tmp; 143 unsigned long tmp;
172 144
173 tmp = readl(i2c->regs + S3C2410_IICCON); 145 tmp = readl(i2c->regs + S3C2410_IICCON);
174 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); 146 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
175} 147}
@@ -177,10 +149,10 @@ static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
177 149
178/* s3c24xx_i2c_message_start 150/* s3c24xx_i2c_message_start
179 * 151 *
180 * put the start of a message onto the bus 152 * put the start of a message onto the bus
181*/ 153*/
182 154
183static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, 155static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
184 struct i2c_msg *msg) 156 struct i2c_msg *msg)
185{ 157{
186 unsigned int addr = (msg->addr & 0x7f) << 1; 158 unsigned int addr = (msg->addr & 0x7f) << 1;
@@ -199,15 +171,15 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
199 if (msg->flags & I2C_M_REV_DIR_ADDR) 171 if (msg->flags & I2C_M_REV_DIR_ADDR)
200 addr ^= 1; 172 addr ^= 1;
201 173
202 // todo - check for wether ack wanted or not 174 /* todo - check for wether ack wanted or not */
203 s3c24xx_i2c_enable_ack(i2c); 175 s3c24xx_i2c_enable_ack(i2c);
204 176
205 iiccon = readl(i2c->regs + S3C2410_IICCON); 177 iiccon = readl(i2c->regs + S3C2410_IICCON);
206 writel(stat, i2c->regs + S3C2410_IICSTAT); 178 writel(stat, i2c->regs + S3C2410_IICSTAT);
207 179
208 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); 180 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
209 writeb(addr, i2c->regs + S3C2410_IICDS); 181 writeb(addr, i2c->regs + S3C2410_IICDS);
210 182
211 /* delay here to ensure the data byte has gotten onto the bus 183 /* delay here to ensure the data byte has gotten onto the bus
212 * before the transaction is started */ 184 * before the transaction is started */
213 185
@@ -215,8 +187,8 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
215 187
216 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); 188 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);
217 writel(iiccon, i2c->regs + S3C2410_IICCON); 189 writel(iiccon, i2c->regs + S3C2410_IICCON);
218 190
219 stat |= S3C2410_IICSTAT_START; 191 stat |= S3C2410_IICSTAT_START;
220 writel(stat, i2c->regs + S3C2410_IICSTAT); 192 writel(stat, i2c->regs + S3C2410_IICSTAT);
221} 193}
222 194
@@ -227,11 +199,11 @@ static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
227 dev_dbg(i2c->dev, "STOP\n"); 199 dev_dbg(i2c->dev, "STOP\n");
228 200
229 /* stop the transfer */ 201 /* stop the transfer */
230 iicstat &= ~ S3C2410_IICSTAT_START; 202 iicstat &= ~S3C2410_IICSTAT_START;
231 writel(iicstat, i2c->regs + S3C2410_IICSTAT); 203 writel(iicstat, i2c->regs + S3C2410_IICSTAT);
232 204
233 i2c->state = STATE_STOP; 205 i2c->state = STATE_STOP;
234 206
235 s3c24xx_i2c_master_complete(i2c, ret); 207 s3c24xx_i2c_master_complete(i2c, ret);
236 s3c24xx_i2c_disable_irq(i2c); 208 s3c24xx_i2c_disable_irq(i2c);
237} 209}
@@ -241,7 +213,7 @@ static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
241 213
242/* is_lastmsg() 214/* is_lastmsg()
243 * 215 *
244 * returns TRUE if the current message is the last in the set 216 * returns TRUE if the current message is the last in the set
245*/ 217*/
246 218
247static inline int is_lastmsg(struct s3c24xx_i2c *i2c) 219static inline int is_lastmsg(struct s3c24xx_i2c *i2c)
@@ -289,14 +261,14 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
289 261
290 case STATE_STOP: 262 case STATE_STOP:
291 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__); 263 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
292 s3c24xx_i2c_disable_irq(i2c); 264 s3c24xx_i2c_disable_irq(i2c);
293 goto out_ack; 265 goto out_ack;
294 266
295 case STATE_START: 267 case STATE_START:
296 /* last thing we did was send a start condition on the 268 /* last thing we did was send a start condition on the
297 * bus, or started a new i2c message 269 * bus, or started a new i2c message
298 */ 270 */
299 271
300 if (iicstat & S3C2410_IICSTAT_LASTBIT && 272 if (iicstat & S3C2410_IICSTAT_LASTBIT &&
301 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { 273 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
302 /* ack was not received... */ 274 /* ack was not received... */
@@ -322,7 +294,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
322 if (i2c->state == STATE_READ) 294 if (i2c->state == STATE_READ)
323 goto prepare_read; 295 goto prepare_read;
324 296
325 /* fall through to the write state, as we will need to 297 /* fall through to the write state, as we will need to
326 * send a byte as well */ 298 * send a byte as well */
327 299
328 case STATE_WRITE: 300 case STATE_WRITE:
@@ -339,7 +311,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
339 } 311 }
340 } 312 }
341 313
342 retry_write: 314 retry_write:
343 315
344 if (!is_msgend(i2c)) { 316 if (!is_msgend(i2c)) {
345 byte = i2c->msg->buf[i2c->msg_ptr++]; 317 byte = i2c->msg->buf[i2c->msg_ptr++];
@@ -359,9 +331,9 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
359 dev_dbg(i2c->dev, "WRITE: Next Message\n"); 331 dev_dbg(i2c->dev, "WRITE: Next Message\n");
360 332
361 i2c->msg_ptr = 0; 333 i2c->msg_ptr = 0;
362 i2c->msg_idx ++; 334 i2c->msg_idx++;
363 i2c->msg++; 335 i2c->msg++;
364 336
365 /* check to see if we need to do another message */ 337 /* check to see if we need to do another message */
366 if (i2c->msg->flags & I2C_M_NOSTART) { 338 if (i2c->msg->flags & I2C_M_NOSTART) {
367 339
@@ -375,7 +347,6 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
375 347
376 goto retry_write; 348 goto retry_write;
377 } else { 349 } else {
378
379 /* send the new start */ 350 /* send the new start */
380 s3c24xx_i2c_message_start(i2c, i2c->msg); 351 s3c24xx_i2c_message_start(i2c, i2c->msg);
381 i2c->state = STATE_START; 352 i2c->state = STATE_START;
@@ -389,7 +360,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
389 break; 360 break;
390 361
391 case STATE_READ: 362 case STATE_READ:
392 /* we have a byte of data in the data register, do 363 /* we have a byte of data in the data register, do
393 * something with it, and then work out wether we are 364 * something with it, and then work out wether we are
394 * going to do any more read/write 365 * going to do any more read/write
395 */ 366 */
@@ -397,13 +368,13 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
397 byte = readb(i2c->regs + S3C2410_IICDS); 368 byte = readb(i2c->regs + S3C2410_IICDS);
398 i2c->msg->buf[i2c->msg_ptr++] = byte; 369 i2c->msg->buf[i2c->msg_ptr++] = byte;
399 370
400 prepare_read: 371 prepare_read:
401 if (is_msglast(i2c)) { 372 if (is_msglast(i2c)) {
402 /* last byte of buffer */ 373 /* last byte of buffer */
403 374
404 if (is_lastmsg(i2c)) 375 if (is_lastmsg(i2c))
405 s3c24xx_i2c_disable_ack(i2c); 376 s3c24xx_i2c_disable_ack(i2c);
406 377
407 } else if (is_msgend(i2c)) { 378 } else if (is_msgend(i2c)) {
408 /* ok, we've read the entire buffer, see if there 379 /* ok, we've read the entire buffer, see if there
409 * is anything else we need to do */ 380 * is anything else we need to do */
@@ -429,7 +400,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
429 /* acknowlegde the IRQ and get back on with the work */ 400 /* acknowlegde the IRQ and get back on with the work */
430 401
431 out_ack: 402 out_ack:
432 tmp = readl(i2c->regs + S3C2410_IICCON); 403 tmp = readl(i2c->regs + S3C2410_IICCON);
433 tmp &= ~S3C2410_IICCON_IRQPEND; 404 tmp &= ~S3C2410_IICCON_IRQPEND;
434 writel(tmp, i2c->regs + S3C2410_IICCON); 405 writel(tmp, i2c->regs + S3C2410_IICCON);
435 out: 406 out:
@@ -450,19 +421,19 @@ static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id)
450 status = readl(i2c->regs + S3C2410_IICSTAT); 421 status = readl(i2c->regs + S3C2410_IICSTAT);
451 422
452 if (status & S3C2410_IICSTAT_ARBITR) { 423 if (status & S3C2410_IICSTAT_ARBITR) {
453 // deal with arbitration loss 424 /* deal with arbitration loss */
454 dev_err(i2c->dev, "deal with arbitration loss\n"); 425 dev_err(i2c->dev, "deal with arbitration loss\n");
455 } 426 }
456 427
457 if (i2c->state == STATE_IDLE) { 428 if (i2c->state == STATE_IDLE) {
458 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n"); 429 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n");
459 430
460 tmp = readl(i2c->regs + S3C2410_IICCON); 431 tmp = readl(i2c->regs + S3C2410_IICCON);
461 tmp &= ~S3C2410_IICCON_IRQPEND; 432 tmp &= ~S3C2410_IICCON_IRQPEND;
462 writel(tmp, i2c->regs + S3C2410_IICCON); 433 writel(tmp, i2c->regs + S3C2410_IICCON);
463 goto out; 434 goto out;
464 } 435 }
465 436
466 /* pretty much this leaves us with the fact that we've 437 /* pretty much this leaves us with the fact that we've
467 * transmitted or received whatever byte we last sent */ 438 * transmitted or received whatever byte we last sent */
468 439
@@ -485,16 +456,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
485 456
486 while (timeout-- > 0) { 457 while (timeout-- > 0) {
487 iicstat = readl(i2c->regs + S3C2410_IICSTAT); 458 iicstat = readl(i2c->regs + S3C2410_IICSTAT);
488 459
489 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY)) 460 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY))
490 return 0; 461 return 0;
491 462
492 msleep(1); 463 msleep(1);
493 } 464 }
494 465
495 dev_dbg(i2c->dev, "timeout: GPEDAT is %08x\n",
496 __raw_readl(S3C2410_GPEDAT));
497
498 return -ETIMEDOUT; 466 return -ETIMEDOUT;
499} 467}
500 468
@@ -503,7 +471,8 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
503 * this starts an i2c transfer 471 * this starts an i2c transfer
504*/ 472*/
505 473
506static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int num) 474static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
475 struct i2c_msg *msgs, int num)
507{ 476{
508 unsigned long timeout; 477 unsigned long timeout;
509 int ret; 478 int ret;
@@ -529,12 +498,12 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
529 s3c24xx_i2c_enable_irq(i2c); 498 s3c24xx_i2c_enable_irq(i2c);
530 s3c24xx_i2c_message_start(i2c, msgs); 499 s3c24xx_i2c_message_start(i2c, msgs);
531 spin_unlock_irq(&i2c->lock); 500 spin_unlock_irq(&i2c->lock);
532 501
533 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); 502 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
534 503
535 ret = i2c->msg_idx; 504 ret = i2c->msg_idx;
536 505
537 /* having these next two as dev_err() makes life very 506 /* having these next two as dev_err() makes life very
538 * noisy when doing an i2cdetect */ 507 * noisy when doing an i2cdetect */
539 508
540 if (timeout == 0) 509 if (timeout == 0)
@@ -591,19 +560,6 @@ static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
591 .functionality = s3c24xx_i2c_func, 560 .functionality = s3c24xx_i2c_func,
592}; 561};
593 562
594static struct s3c24xx_i2c s3c24xx_i2c = {
595 .lock = __SPIN_LOCK_UNLOCKED(s3c24xx_i2c.lock),
596 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
597 .tx_setup = 50,
598 .adap = {
599 .name = "s3c2410-i2c",
600 .owner = THIS_MODULE,
601 .algo = &s3c24xx_i2c_algorithm,
602 .retries = 2,
603 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
604 },
605};
606
607/* s3c24xx_i2c_calcdivisor 563/* s3c24xx_i2c_calcdivisor
608 * 564 *
609 * return the divisor settings for a given frequency 565 * return the divisor settings for a given frequency
@@ -643,7 +599,7 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
643{ 599{
644 int diff = freq - wanted; 600 int diff = freq - wanted;
645 601
646 return (diff >= -2 && diff <= 2); 602 return diff >= -2 && diff <= 2;
647} 603}
648 604
649/* s3c24xx_i2c_clockrate 605/* s3c24xx_i2c_clockrate
@@ -655,7 +611,7 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
655 611
656static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) 612static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
657{ 613{
658 struct s3c2410_platform_i2c *pdata; 614 struct s3c2410_platform_i2c *pdata = i2c->dev->platform_data;
659 unsigned long clkin = clk_get_rate(i2c->clk); 615 unsigned long clkin = clk_get_rate(i2c->clk);
660 unsigned int divs, div1; 616 unsigned int divs, div1;
661 u32 iiccon; 617 u32 iiccon;
@@ -663,10 +619,8 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
663 int start, end; 619 int start, end;
664 620
665 i2c->clkrate = clkin; 621 i2c->clkrate = clkin;
666
667 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
668 clkin /= 1000; /* clkin now in KHz */ 622 clkin /= 1000; /* clkin now in KHz */
669 623
670 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n", 624 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",
671 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq); 625 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);
672 626
@@ -774,7 +728,7 @@ static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c)
774 728
775/* s3c24xx_i2c_init 729/* s3c24xx_i2c_init
776 * 730 *
777 * initialise the controller, set the IO lines and frequency 731 * initialise the controller, set the IO lines and frequency
778*/ 732*/
779 733
780static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) 734static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
@@ -785,15 +739,15 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
785 739
786 /* get the plafrom data */ 740 /* get the plafrom data */
787 741
788 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent); 742 pdata = i2c->dev->platform_data;
789 743
790 /* inititalise the gpio */ 744 /* inititalise the gpio */
791 745
792 s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA); 746 if (pdata->cfg_gpio)
793 s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL); 747 pdata->cfg_gpio(to_platform_device(i2c->dev));
794 748
795 /* write slave address */ 749 /* write slave address */
796 750
797 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD); 751 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD);
798 752
799 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); 753 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
@@ -831,12 +785,32 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
831 785
832static int s3c24xx_i2c_probe(struct platform_device *pdev) 786static int s3c24xx_i2c_probe(struct platform_device *pdev)
833{ 787{
834 struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 788 struct s3c24xx_i2c *i2c;
835 struct s3c2410_platform_i2c *pdata; 789 struct s3c2410_platform_i2c *pdata;
836 struct resource *res; 790 struct resource *res;
837 int ret; 791 int ret;
838 792
839 pdata = s3c24xx_i2c_get_platformdata(&pdev->dev); 793 pdata = pdev->dev.platform_data;
794 if (!pdata) {
795 dev_err(&pdev->dev, "no platform data\n");
796 return -EINVAL;
797 }
798
799 i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
800 if (!i2c) {
801 dev_err(&pdev->dev, "no memory for state\n");
802 return -ENOMEM;
803 }
804
805 strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name));
806 i2c->adap.owner = THIS_MODULE;
807 i2c->adap.algo = &s3c24xx_i2c_algorithm;
808 i2c->adap.retries = 2;
809 i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
810 i2c->tx_setup = 50;
811
812 spin_lock_init(&i2c->lock);
813 init_waitqueue_head(&i2c->wait);
840 814
841 /* find the clock and enable it */ 815 /* find the clock and enable it */
842 816
@@ -878,7 +852,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
878 goto err_ioarea; 852 goto err_ioarea;
879 } 853 }
880 854
881 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res); 855 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
856 i2c->regs, i2c->ioarea, res);
882 857
883 /* setup info block for the i2c core */ 858 /* setup info block for the i2c core */
884 859
@@ -892,29 +867,23 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
892 goto err_iomap; 867 goto err_iomap;
893 868
894 /* find the IRQ for this unit (note, this relies on the init call to 869 /* find the IRQ for this unit (note, this relies on the init call to
895 * ensure no current IRQs pending 870 * ensure no current IRQs pending
896 */ 871 */
897 872
898 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 873 i2c->irq = ret = platform_get_irq(pdev, 0);
899 if (res == NULL) { 874 if (ret <= 0) {
900 dev_err(&pdev->dev, "cannot find IRQ\n"); 875 dev_err(&pdev->dev, "cannot find IRQ\n");
901 ret = -ENOENT;
902 goto err_iomap; 876 goto err_iomap;
903 } 877 }
904 878
905 ret = request_irq(res->start, s3c24xx_i2c_irq, IRQF_DISABLED, 879 ret = request_irq(i2c->irq, s3c24xx_i2c_irq, IRQF_DISABLED,
906 pdev->name, i2c); 880 dev_name(&pdev->dev), i2c);
907 881
908 if (ret != 0) { 882 if (ret != 0) {
909 dev_err(&pdev->dev, "cannot claim IRQ\n"); 883 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
910 goto err_iomap; 884 goto err_iomap;
911 } 885 }
912 886
913 i2c->irq = res;
914
915 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,
916 (unsigned long)res->start);
917
918 ret = s3c24xx_i2c_register_cpufreq(i2c); 887 ret = s3c24xx_i2c_register_cpufreq(i2c);
919 if (ret < 0) { 888 if (ret < 0) {
920 dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); 889 dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
@@ -944,7 +913,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
944 s3c24xx_i2c_deregister_cpufreq(i2c); 913 s3c24xx_i2c_deregister_cpufreq(i2c);
945 914
946 err_irq: 915 err_irq:
947 free_irq(i2c->irq->start, i2c); 916 free_irq(i2c->irq, i2c);
948 917
949 err_iomap: 918 err_iomap:
950 iounmap(i2c->regs); 919 iounmap(i2c->regs);
@@ -958,6 +927,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
958 clk_put(i2c->clk); 927 clk_put(i2c->clk);
959 928
960 err_noclk: 929 err_noclk:
930 kfree(i2c);
961 return ret; 931 return ret;
962} 932}
963 933
@@ -973,7 +943,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
973 s3c24xx_i2c_deregister_cpufreq(i2c); 943 s3c24xx_i2c_deregister_cpufreq(i2c);
974 944
975 i2c_del_adapter(&i2c->adap); 945 i2c_del_adapter(&i2c->adap);
976 free_irq(i2c->irq->start, i2c); 946 free_irq(i2c->irq, i2c);
977 947
978 clk_disable(i2c->clk); 948 clk_disable(i2c->clk);
979 clk_put(i2c->clk); 949 clk_put(i2c->clk);
@@ -982,6 +952,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
982 952
983 release_resource(i2c->ioarea); 953 release_resource(i2c->ioarea);
984 kfree(i2c->ioarea); 954 kfree(i2c->ioarea);
955 kfree(i2c);
985 956
986 return 0; 957 return 0;
987} 958}
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index 53912c327bfe..8dc2bb781605 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -57,9 +57,6 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry,
57 } 57 }
58 58
59 inode->i_mode = mode; 59 inode->i_mode = mode;
60 inode->i_uid = 0;
61 inode->i_gid = 0;
62 inode->i_blocks = 0;
63 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 60 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
64 inode->i_private = data; 61 inode->i_private = data;
65 if ((mode & S_IFMT) == S_IFDIR) { 62 if ((mode & S_IFMT) == S_IFDIR) {
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
index d5b4cc357a3c..650120261abf 100644
--- a/drivers/isdn/capi/capidrv.c
+++ b/drivers/isdn/capi/capidrv.c
@@ -1519,7 +1519,7 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep)
1519 int digit2 = 0; 1519 int digit2 = 0;
1520 if (!isdigit(*s)) return -3; 1520 if (!isdigit(*s)) return -3;
1521 while (isdigit(*s)) { digit1 = digit1*10 + (*s - '0'); s++; } 1521 while (isdigit(*s)) { digit1 = digit1*10 + (*s - '0'); s++; }
1522 if (digit1 <= 0 && digit1 > 30) return -4; 1522 if (digit1 <= 0 || digit1 > 30) return -4;
1523 if (*s == 0 || *s == ',' || *s == ' ') { 1523 if (*s == 0 || *s == ',' || *s == ' ') {
1524 bmask |= (1 << digit1); 1524 bmask |= (1 << digit1);
1525 digit1 = 0; 1525 digit1 = 0;
@@ -1530,7 +1530,7 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep)
1530 s++; 1530 s++;
1531 if (!isdigit(*s)) return -3; 1531 if (!isdigit(*s)) return -3;
1532 while (isdigit(*s)) { digit2 = digit2*10 + (*s - '0'); s++; } 1532 while (isdigit(*s)) { digit2 = digit2*10 + (*s - '0'); s++; }
1533 if (digit2 <= 0 && digit2 > 30) return -4; 1533 if (digit2 <= 0 || digit2 > 30) return -4;
1534 if (*s == 0 || *s == ',' || *s == ' ') { 1534 if (*s == 0 || *s == ',' || *s == ' ') {
1535 if (digit1 > digit2) 1535 if (digit1 > digit2)
1536 for (i = digit2; i <= digit1 ; i++) 1536 for (i = digit2; i <= digit1 ; i++)
diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c
index 0aa66ec4cbdd..b129409925af 100644
--- a/drivers/isdn/capi/capifs.c
+++ b/drivers/isdn/capi/capifs.c
@@ -111,8 +111,6 @@ capifs_fill_super(struct super_block *s, void *data, int silent)
111 goto fail; 111 goto fail;
112 inode->i_ino = 1; 112 inode->i_ino = 1;
113 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 113 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
114 inode->i_blocks = 0;
115 inode->i_uid = inode->i_gid = 0;
116 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 114 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
117 inode->i_op = &simple_dir_inode_operations; 115 inode->i_op = &simple_dir_inode_operations;
118 inode->i_fop = &simple_dir_operations; 116 inode->i_fop = &simple_dir_operations;
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 56faef1a1d55..06c655c55587 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -19,7 +19,7 @@
19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> 19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
20 * Deepak Saxena <deepak@plexity.net> 20 * Deepak Saxena <deepak@plexity.net>
21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com> 21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * Ported to Linux 2.5. 23 * Ported to Linux 2.5.
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Minor fixes for 2.6. 25 * Minor fixes for 2.6.
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index f3384c32b9a1..efba7021948a 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -19,7 +19,7 @@
19 * Changed ioctl_swdl(), implemented ioctl_swul() and ioctl_swdel() 19 * Changed ioctl_swdl(), implemented ioctl_swul() and ioctl_swdel()
20 * Deepak Saxena (11/18/1999): 20 * Deepak Saxena (11/18/1999):
21 * Added event managmenet support 21 * Added event managmenet support
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * 2.4 rewrite ported to 2.5 23 * 2.4 rewrite ported to 2.5
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Added pass-thru support for Adaptec's raidutils 25 * Added pass-thru support for Adaptec's raidutils
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 6e53a30bfd38..35c67d1f255e 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -19,7 +19,7 @@
19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> 19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
20 * Deepak Saxena <deepak@plexity.net> 20 * Deepak Saxena <deepak@plexity.net>
21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com> 21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * Ported to Linux 2.5. 23 * Ported to Linux 2.5.
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Minor fixes for 2.6. 25 * Minor fixes for 2.6.
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 610ef1204e68..25d6f2341983 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -19,7 +19,7 @@
19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> 19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
20 * Deepak Saxena <deepak@plexity.net> 20 * Deepak Saxena <deepak@plexity.net>
21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com> 21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * Ported to Linux 2.5. 23 * Ported to Linux 2.5.
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Minor fixes for 2.6. 25 * Minor fixes for 2.6.
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index 22a7e8ba211d..de966a6fb7e6 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -146,8 +146,6 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
146 146
147 if (ret) { 147 if (ret) {
148 ret->i_mode = mode; 148 ret->i_mode = mode;
149 ret->i_uid = ret->i_gid = 0;
150 ret->i_blocks = 0;
151 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 149 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
152 } 150 }
153 return ret; 151 return ret;
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 517fce48d94a..5b396ff6c83f 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -66,6 +66,7 @@
66#include <linux/mm.h> 66#include <linux/mm.h>
67#include <linux/highmem.h> 67#include <linux/highmem.h>
68#include <linux/sockios.h> 68#include <linux/sockios.h>
69#include <linux/firmware.h>
69 70
70#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 71#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
71#include <linux/if_vlan.h> 72#include <linux/if_vlan.h>
@@ -186,8 +187,6 @@ MODULE_DEVICE_TABLE(pci, acenic_pci_tbl);
186#define MAX_RODATA_LEN 8*1024 187#define MAX_RODATA_LEN 8*1024
187#define MAX_DATA_LEN 2*1024 188#define MAX_DATA_LEN 2*1024
188 189
189#include "acenic_firmware.h"
190
191#ifndef tigon2FwReleaseLocal 190#ifndef tigon2FwReleaseLocal
192#define tigon2FwReleaseLocal 0 191#define tigon2FwReleaseLocal 0
193#endif 192#endif
@@ -417,6 +416,10 @@ static int dis_pci_mem_inval[ACE_MAX_MOD_PARMS] = {1, 1, 1, 1, 1, 1, 1, 1};
417MODULE_AUTHOR("Jes Sorensen <jes@trained-monkey.org>"); 416MODULE_AUTHOR("Jes Sorensen <jes@trained-monkey.org>");
418MODULE_LICENSE("GPL"); 417MODULE_LICENSE("GPL");
419MODULE_DESCRIPTION("AceNIC/3C985/GA620 Gigabit Ethernet driver"); 418MODULE_DESCRIPTION("AceNIC/3C985/GA620 Gigabit Ethernet driver");
419#ifndef CONFIG_ACENIC_OMIT_TIGON_I
420MODULE_FIRMWARE("acenic/tg1.bin");
421#endif
422MODULE_FIRMWARE("acenic/tg2.bin");
420 423
421module_param_array_named(link, link_state, int, NULL, 0); 424module_param_array_named(link, link_state, int, NULL, 0);
422module_param_array(trace, int, NULL, 0); 425module_param_array(trace, int, NULL, 0);
@@ -943,8 +946,8 @@ static int __devinit ace_init(struct net_device *dev)
943 case 4: 946 case 4:
944 case 5: 947 case 5:
945 printk(KERN_INFO " Tigon I (Rev. %i), Firmware: %i.%i.%i, ", 948 printk(KERN_INFO " Tigon I (Rev. %i), Firmware: %i.%i.%i, ",
946 tig_ver, tigonFwReleaseMajor, tigonFwReleaseMinor, 949 tig_ver, ap->firmware_major, ap->firmware_minor,
947 tigonFwReleaseFix); 950 ap->firmware_fix);
948 writel(0, &regs->LocalCtrl); 951 writel(0, &regs->LocalCtrl);
949 ap->version = 1; 952 ap->version = 1;
950 ap->tx_ring_entries = TIGON_I_TX_RING_ENTRIES; 953 ap->tx_ring_entries = TIGON_I_TX_RING_ENTRIES;
@@ -952,8 +955,8 @@ static int __devinit ace_init(struct net_device *dev)
952#endif 955#endif
953 case 6: 956 case 6:
954 printk(KERN_INFO " Tigon II (Rev. %i), Firmware: %i.%i.%i, ", 957 printk(KERN_INFO " Tigon II (Rev. %i), Firmware: %i.%i.%i, ",
955 tig_ver, tigon2FwReleaseMajor, tigon2FwReleaseMinor, 958 tig_ver, ap->firmware_major, ap->firmware_minor,
956 tigon2FwReleaseFix); 959 ap->firmware_fix);
957 writel(readl(&regs->CpuBCtrl) | CPU_HALT, &regs->CpuBCtrl); 960 writel(readl(&regs->CpuBCtrl) | CPU_HALT, &regs->CpuBCtrl);
958 readl(&regs->CpuBCtrl); /* PCI write posting */ 961 readl(&regs->CpuBCtrl); /* PCI write posting */
959 /* 962 /*
@@ -1205,7 +1208,9 @@ static int __devinit ace_init(struct net_device *dev)
1205 memset(ap->info, 0, sizeof(struct ace_info)); 1208 memset(ap->info, 0, sizeof(struct ace_info));
1206 memset(ap->skb, 0, sizeof(struct ace_skb)); 1209 memset(ap->skb, 0, sizeof(struct ace_skb));
1207 1210
1208 ace_load_firmware(dev); 1211 if (ace_load_firmware(dev))
1212 goto init_error;
1213
1209 ap->fw_running = 0; 1214 ap->fw_running = 0;
1210 1215
1211 tmp_ptr = ap->info_dma; 1216 tmp_ptr = ap->info_dma;
@@ -1441,10 +1446,7 @@ static int __devinit ace_init(struct net_device *dev)
1441 if (ap->version >= 2) 1446 if (ap->version >= 2)
1442 writel(tmp, &regs->TuneFastLink); 1447 writel(tmp, &regs->TuneFastLink);
1443 1448
1444 if (ACE_IS_TIGON_I(ap)) 1449 writel(ap->firmware_start, &regs->Pc);
1445 writel(tigonFwStartAddr, &regs->Pc);
1446 if (ap->version == 2)
1447 writel(tigon2FwStartAddr, &regs->Pc);
1448 1450
1449 writel(0, &regs->Mb0Lo); 1451 writel(0, &regs->Mb0Lo);
1450 1452
@@ -2761,8 +2763,8 @@ static void ace_get_drvinfo(struct net_device *dev,
2761 2763
2762 strlcpy(info->driver, "acenic", sizeof(info->driver)); 2764 strlcpy(info->driver, "acenic", sizeof(info->driver));
2763 snprintf(info->version, sizeof(info->version), "%i.%i.%i", 2765 snprintf(info->version, sizeof(info->version), "%i.%i.%i",
2764 tigonFwReleaseMajor, tigonFwReleaseMinor, 2766 ap->firmware_major, ap->firmware_minor,
2765 tigonFwReleaseFix); 2767 ap->firmware_fix);
2766 2768
2767 if (ap->pdev) 2769 if (ap->pdev)
2768 strlcpy(info->bus_info, pci_name(ap->pdev), 2770 strlcpy(info->bus_info, pci_name(ap->pdev),
@@ -2869,11 +2871,10 @@ static struct net_device_stats *ace_get_stats(struct net_device *dev)
2869} 2871}
2870 2872
2871 2873
2872static void __devinit ace_copy(struct ace_regs __iomem *regs, void *src, 2874static void __devinit ace_copy(struct ace_regs __iomem *regs, const __be32 *src,
2873 u32 dest, int size) 2875 u32 dest, int size)
2874{ 2876{
2875 void __iomem *tdest; 2877 void __iomem *tdest;
2876 u32 *wsrc;
2877 short tsize, i; 2878 short tsize, i;
2878 2879
2879 if (size <= 0) 2880 if (size <= 0)
@@ -2885,20 +2886,15 @@ static void __devinit ace_copy(struct ace_regs __iomem *regs, void *src,
2885 tdest = (void __iomem *) &regs->Window + 2886 tdest = (void __iomem *) &regs->Window +
2886 (dest & (ACE_WINDOW_SIZE - 1)); 2887 (dest & (ACE_WINDOW_SIZE - 1));
2887 writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase); 2888 writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase);
2888 /*
2889 * This requires byte swapping on big endian, however
2890 * writel does that for us
2891 */
2892 wsrc = src;
2893 for (i = 0; i < (tsize / 4); i++) { 2889 for (i = 0; i < (tsize / 4); i++) {
2894 writel(wsrc[i], tdest + i*4); 2890 /* Firmware is big-endian */
2891 writel(be32_to_cpup(src), tdest);
2892 src++;
2893 tdest += 4;
2894 dest += 4;
2895 size -= 4;
2895 } 2896 }
2896 dest += tsize;
2897 src += tsize;
2898 size -= tsize;
2899 } 2897 }
2900
2901 return;
2902} 2898}
2903 2899
2904 2900
@@ -2937,8 +2933,13 @@ static void __devinit ace_clear(struct ace_regs __iomem *regs, u32 dest, int siz
2937 */ 2933 */
2938static int __devinit ace_load_firmware(struct net_device *dev) 2934static int __devinit ace_load_firmware(struct net_device *dev)
2939{ 2935{
2936 const struct firmware *fw;
2937 const char *fw_name = "acenic/tg2.bin";
2940 struct ace_private *ap = netdev_priv(dev); 2938 struct ace_private *ap = netdev_priv(dev);
2941 struct ace_regs __iomem *regs = ap->regs; 2939 struct ace_regs __iomem *regs = ap->regs;
2940 const __be32 *fw_data;
2941 u32 load_addr;
2942 int ret;
2942 2943
2943 if (!(readl(&regs->CpuCtrl) & CPU_HALTED)) { 2944 if (!(readl(&regs->CpuCtrl) & CPU_HALTED)) {
2944 printk(KERN_ERR "%s: trying to download firmware while the " 2945 printk(KERN_ERR "%s: trying to download firmware while the "
@@ -2946,28 +2947,52 @@ static int __devinit ace_load_firmware(struct net_device *dev)
2946 return -EFAULT; 2947 return -EFAULT;
2947 } 2948 }
2948 2949
2950 if (ACE_IS_TIGON_I(ap))
2951 fw_name = "acenic/tg1.bin";
2952
2953 ret = request_firmware(&fw, fw_name, &ap->pdev->dev);
2954 if (ret) {
2955 printk(KERN_ERR "%s: Failed to load firmware \"%s\"\n",
2956 ap->name, fw_name);
2957 return ret;
2958 }
2959
2960 fw_data = (void *)fw->data;
2961
2962 /* Firmware blob starts with version numbers, followed by
2963 load and start address. Remainder is the blob to be loaded
2964 contiguously from load address. We don't bother to represent
2965 the BSS/SBSS sections any more, since we were clearing the
2966 whole thing anyway. */
2967 ap->firmware_major = fw->data[0];
2968 ap->firmware_minor = fw->data[1];
2969 ap->firmware_fix = fw->data[2];
2970
2971 ap->firmware_start = be32_to_cpu(fw_data[1]);
2972 if (ap->firmware_start < 0x4000 || ap->firmware_start >= 0x80000) {
2973 printk(KERN_ERR "%s: bogus load address %08x in \"%s\"\n",
2974 ap->name, ap->firmware_start, fw_name);
2975 ret = -EINVAL;
2976 goto out;
2977 }
2978
2979 load_addr = be32_to_cpu(fw_data[2]);
2980 if (load_addr < 0x4000 || load_addr >= 0x80000) {
2981 printk(KERN_ERR "%s: bogus load address %08x in \"%s\"\n",
2982 ap->name, load_addr, fw_name);
2983 ret = -EINVAL;
2984 goto out;
2985 }
2986
2949 /* 2987 /*
2950 * Do not try to clear more than 512KB or we end up seeing 2988 * Do not try to clear more than 512KiB or we end up seeing
2951 * funny things on NICs with only 512KB SRAM 2989 * funny things on NICs with only 512KiB SRAM
2952 */ 2990 */
2953 ace_clear(regs, 0x2000, 0x80000-0x2000); 2991 ace_clear(regs, 0x2000, 0x80000-0x2000);
2954 if (ACE_IS_TIGON_I(ap)) { 2992 ace_copy(regs, &fw_data[3], load_addr, fw->size-12);
2955 ace_copy(regs, tigonFwText, tigonFwTextAddr, tigonFwTextLen); 2993 out:
2956 ace_copy(regs, tigonFwData, tigonFwDataAddr, tigonFwDataLen); 2994 release_firmware(fw);
2957 ace_copy(regs, tigonFwRodata, tigonFwRodataAddr, 2995 return ret;
2958 tigonFwRodataLen);
2959 ace_clear(regs, tigonFwBssAddr, tigonFwBssLen);
2960 ace_clear(regs, tigonFwSbssAddr, tigonFwSbssLen);
2961 }else if (ap->version == 2) {
2962 ace_clear(regs, tigon2FwBssAddr, tigon2FwBssLen);
2963 ace_clear(regs, tigon2FwSbssAddr, tigon2FwSbssLen);
2964 ace_copy(regs, tigon2FwText, tigon2FwTextAddr,tigon2FwTextLen);
2965 ace_copy(regs, tigon2FwRodata, tigon2FwRodataAddr,
2966 tigon2FwRodataLen);
2967 ace_copy(regs, tigon2FwData, tigon2FwDataAddr,tigon2FwDataLen);
2968 }
2969
2970 return 0;
2971} 2996}
2972 2997
2973 2998
diff --git a/drivers/net/acenic.h b/drivers/net/acenic.h
index 4487f32759a4..c987c9b5a137 100644
--- a/drivers/net/acenic.h
+++ b/drivers/net/acenic.h
@@ -694,6 +694,10 @@ struct ace_private
694 u32 last_tx, last_std_rx, last_mini_rx; 694 u32 last_tx, last_std_rx, last_mini_rx;
695#endif 695#endif
696 int pci_using_dac; 696 int pci_using_dac;
697 u8 firmware_major;
698 u8 firmware_minor;
699 u8 firmware_fix;
700 u32 firmware_start;
697}; 701};
698 702
699 703
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 9f38b16ccbbd..134b2d60b479 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -658,12 +658,12 @@ static int e100_self_test(struct nic *nic)
658 e100_disable_irq(nic); 658 e100_disable_irq(nic);
659 659
660 /* Check results of self-test */ 660 /* Check results of self-test */
661 if(nic->mem->selftest.result != 0) { 661 if (nic->mem->selftest.result != 0) {
662 DPRINTK(HW, ERR, "Self-test failed: result=0x%08X\n", 662 DPRINTK(HW, ERR, "Self-test failed: result=0x%08X\n",
663 nic->mem->selftest.result); 663 nic->mem->selftest.result);
664 return -ETIMEDOUT; 664 return -ETIMEDOUT;
665 } 665 }
666 if(nic->mem->selftest.signature == 0) { 666 if (nic->mem->selftest.signature == 0) {
667 DPRINTK(HW, ERR, "Self-test failed: timed out\n"); 667 DPRINTK(HW, ERR, "Self-test failed: timed out\n");
668 return -ETIMEDOUT; 668 return -ETIMEDOUT;
669 } 669 }
@@ -684,13 +684,13 @@ static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, __le16 da
684 cmd_addr_data[2] = op_ewds << (addr_len - 2); 684 cmd_addr_data[2] = op_ewds << (addr_len - 2);
685 685
686 /* Bit-bang cmds to write word to eeprom */ 686 /* Bit-bang cmds to write word to eeprom */
687 for(j = 0; j < 3; j++) { 687 for (j = 0; j < 3; j++) {
688 688
689 /* Chip select */ 689 /* Chip select */
690 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo); 690 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo);
691 e100_write_flush(nic); udelay(4); 691 e100_write_flush(nic); udelay(4);
692 692
693 for(i = 31; i >= 0; i--) { 693 for (i = 31; i >= 0; i--) {
694 ctrl = (cmd_addr_data[j] & (1 << i)) ? 694 ctrl = (cmd_addr_data[j] & (1 << i)) ?
695 eecs | eedi : eecs; 695 eecs | eedi : eecs;
696 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); 696 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo);
@@ -723,7 +723,7 @@ static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)
723 e100_write_flush(nic); udelay(4); 723 e100_write_flush(nic); udelay(4);
724 724
725 /* Bit-bang to read word from eeprom */ 725 /* Bit-bang to read word from eeprom */
726 for(i = 31; i >= 0; i--) { 726 for (i = 31; i >= 0; i--) {
727 ctrl = (cmd_addr_data & (1 << i)) ? eecs | eedi : eecs; 727 ctrl = (cmd_addr_data & (1 << i)) ? eecs | eedi : eecs;
728 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); 728 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo);
729 e100_write_flush(nic); udelay(4); 729 e100_write_flush(nic); udelay(4);
@@ -734,7 +734,7 @@ static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)
734 /* Eeprom drives a dummy zero to EEDO after receiving 734 /* Eeprom drives a dummy zero to EEDO after receiving
735 * complete address. Use this to adjust addr_len. */ 735 * complete address. Use this to adjust addr_len. */
736 ctrl = ioread8(&nic->csr->eeprom_ctrl_lo); 736 ctrl = ioread8(&nic->csr->eeprom_ctrl_lo);
737 if(!(ctrl & eedo) && i > 16) { 737 if (!(ctrl & eedo) && i > 16) {
738 *addr_len -= (i - 16); 738 *addr_len -= (i - 16);
739 i = 17; 739 i = 17;
740 } 740 }
@@ -758,9 +758,9 @@ static int e100_eeprom_load(struct nic *nic)
758 e100_eeprom_read(nic, &addr_len, 0); 758 e100_eeprom_read(nic, &addr_len, 0);
759 nic->eeprom_wc = 1 << addr_len; 759 nic->eeprom_wc = 1 << addr_len;
760 760
761 for(addr = 0; addr < nic->eeprom_wc; addr++) { 761 for (addr = 0; addr < nic->eeprom_wc; addr++) {
762 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr); 762 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr);
763 if(addr < nic->eeprom_wc - 1) 763 if (addr < nic->eeprom_wc - 1)
764 checksum += le16_to_cpu(nic->eeprom[addr]); 764 checksum += le16_to_cpu(nic->eeprom[addr]);
765 } 765 }
766 766
@@ -784,15 +784,15 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)
784 e100_eeprom_read(nic, &addr_len, 0); 784 e100_eeprom_read(nic, &addr_len, 0);
785 nic->eeprom_wc = 1 << addr_len; 785 nic->eeprom_wc = 1 << addr_len;
786 786
787 if(start + count >= nic->eeprom_wc) 787 if (start + count >= nic->eeprom_wc)
788 return -EINVAL; 788 return -EINVAL;
789 789
790 for(addr = start; addr < start + count; addr++) 790 for (addr = start; addr < start + count; addr++)
791 e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]); 791 e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]);
792 792
793 /* The checksum, stored in the last word, is calculated such that 793 /* The checksum, stored in the last word, is calculated such that
794 * the sum of words should be 0xBABA */ 794 * the sum of words should be 0xBABA */
795 for(addr = 0; addr < nic->eeprom_wc - 1; addr++) 795 for (addr = 0; addr < nic->eeprom_wc - 1; addr++)
796 checksum += le16_to_cpu(nic->eeprom[addr]); 796 checksum += le16_to_cpu(nic->eeprom[addr]);
797 nic->eeprom[nic->eeprom_wc - 1] = cpu_to_le16(0xBABA - checksum); 797 nic->eeprom[nic->eeprom_wc - 1] = cpu_to_le16(0xBABA - checksum);
798 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1, 798 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1,
@@ -812,19 +812,19 @@ static int e100_exec_cmd(struct nic *nic, u8 cmd, dma_addr_t dma_addr)
812 spin_lock_irqsave(&nic->cmd_lock, flags); 812 spin_lock_irqsave(&nic->cmd_lock, flags);
813 813
814 /* Previous command is accepted when SCB clears */ 814 /* Previous command is accepted when SCB clears */
815 for(i = 0; i < E100_WAIT_SCB_TIMEOUT; i++) { 815 for (i = 0; i < E100_WAIT_SCB_TIMEOUT; i++) {
816 if(likely(!ioread8(&nic->csr->scb.cmd_lo))) 816 if (likely(!ioread8(&nic->csr->scb.cmd_lo)))
817 break; 817 break;
818 cpu_relax(); 818 cpu_relax();
819 if(unlikely(i > E100_WAIT_SCB_FAST)) 819 if (unlikely(i > E100_WAIT_SCB_FAST))
820 udelay(5); 820 udelay(5);
821 } 821 }
822 if(unlikely(i == E100_WAIT_SCB_TIMEOUT)) { 822 if (unlikely(i == E100_WAIT_SCB_TIMEOUT)) {
823 err = -EAGAIN; 823 err = -EAGAIN;
824 goto err_unlock; 824 goto err_unlock;
825 } 825 }
826 826
827 if(unlikely(cmd != cuc_resume)) 827 if (unlikely(cmd != cuc_resume))
828 iowrite32(dma_addr, &nic->csr->scb.gen_ptr); 828 iowrite32(dma_addr, &nic->csr->scb.gen_ptr);
829 iowrite8(cmd, &nic->csr->scb.cmd_lo); 829 iowrite8(cmd, &nic->csr->scb.cmd_lo);
830 830
@@ -843,7 +843,7 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
843 843
844 spin_lock_irqsave(&nic->cb_lock, flags); 844 spin_lock_irqsave(&nic->cb_lock, flags);
845 845
846 if(unlikely(!nic->cbs_avail)) { 846 if (unlikely(!nic->cbs_avail)) {
847 err = -ENOMEM; 847 err = -ENOMEM;
848 goto err_unlock; 848 goto err_unlock;
849 } 849 }
@@ -853,7 +853,7 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
853 nic->cbs_avail--; 853 nic->cbs_avail--;
854 cb->skb = skb; 854 cb->skb = skb;
855 855
856 if(unlikely(!nic->cbs_avail)) 856 if (unlikely(!nic->cbs_avail))
857 err = -ENOSPC; 857 err = -ENOSPC;
858 858
859 cb_prepare(nic, cb, skb); 859 cb_prepare(nic, cb, skb);
@@ -864,15 +864,15 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
864 wmb(); 864 wmb();
865 cb->prev->command &= cpu_to_le16(~cb_s); 865 cb->prev->command &= cpu_to_le16(~cb_s);
866 866
867 while(nic->cb_to_send != nic->cb_to_use) { 867 while (nic->cb_to_send != nic->cb_to_use) {
868 if(unlikely(e100_exec_cmd(nic, nic->cuc_cmd, 868 if (unlikely(e100_exec_cmd(nic, nic->cuc_cmd,
869 nic->cb_to_send->dma_addr))) { 869 nic->cb_to_send->dma_addr))) {
870 /* Ok, here's where things get sticky. It's 870 /* Ok, here's where things get sticky. It's
871 * possible that we can't schedule the command 871 * possible that we can't schedule the command
872 * because the controller is too busy, so 872 * because the controller is too busy, so
873 * let's just queue the command and try again 873 * let's just queue the command and try again
874 * when another command is scheduled. */ 874 * when another command is scheduled. */
875 if(err == -ENOSPC) { 875 if (err == -ENOSPC) {
876 //request a reset 876 //request a reset
877 schedule_work(&nic->tx_timeout_task); 877 schedule_work(&nic->tx_timeout_task);
878 } 878 }
@@ -945,7 +945,7 @@ static void e100_get_defaults(struct nic *nic)
945 945
946 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */ 946 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */
947 nic->mac = (nic->flags & ich) ? mac_82559_D101M : nic->pdev->revision; 947 nic->mac = (nic->flags & ich) ? mac_82559_D101M : nic->pdev->revision;
948 if(nic->mac == mac_unknown) 948 if (nic->mac == mac_unknown)
949 nic->mac = mac_82557_D100_A; 949 nic->mac = mac_82557_D100_A;
950 950
951 nic->params.rfds = rfds; 951 nic->params.rfds = rfds;
@@ -1008,23 +1008,23 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1008 config->adaptive_ifs = nic->adaptive_ifs; 1008 config->adaptive_ifs = nic->adaptive_ifs;
1009 config->loopback = nic->loopback; 1009 config->loopback = nic->loopback;
1010 1010
1011 if(nic->mii.force_media && nic->mii.full_duplex) 1011 if (nic->mii.force_media && nic->mii.full_duplex)
1012 config->full_duplex_force = 0x1; /* 1=force, 0=auto */ 1012 config->full_duplex_force = 0x1; /* 1=force, 0=auto */
1013 1013
1014 if(nic->flags & promiscuous || nic->loopback) { 1014 if (nic->flags & promiscuous || nic->loopback) {
1015 config->rx_save_bad_frames = 0x1; /* 1=save, 0=discard */ 1015 config->rx_save_bad_frames = 0x1; /* 1=save, 0=discard */
1016 config->rx_discard_short_frames = 0x0; /* 1=discard, 0=save */ 1016 config->rx_discard_short_frames = 0x0; /* 1=discard, 0=save */
1017 config->promiscuous_mode = 0x1; /* 1=on, 0=off */ 1017 config->promiscuous_mode = 0x1; /* 1=on, 0=off */
1018 } 1018 }
1019 1019
1020 if(nic->flags & multicast_all) 1020 if (nic->flags & multicast_all)
1021 config->multicast_all = 0x1; /* 1=accept, 0=no */ 1021 config->multicast_all = 0x1; /* 1=accept, 0=no */
1022 1022
1023 /* disable WoL when up */ 1023 /* disable WoL when up */
1024 if(netif_running(nic->netdev) || !(nic->flags & wol_magic)) 1024 if (netif_running(nic->netdev) || !(nic->flags & wol_magic))
1025 config->magic_packet_disable = 0x1; /* 1=off, 0=on */ 1025 config->magic_packet_disable = 0x1; /* 1=off, 0=on */
1026 1026
1027 if(nic->mac >= mac_82558_D101_A4) { 1027 if (nic->mac >= mac_82558_D101_A4) {
1028 config->fc_disable = 0x1; /* 1=Tx fc off, 0=Tx fc on */ 1028 config->fc_disable = 0x1; /* 1=Tx fc off, 0=Tx fc on */
1029 config->mwi_enable = 0x1; /* 1=enable, 0=disable */ 1029 config->mwi_enable = 0x1; /* 1=enable, 0=disable */
1030 config->standard_tcb = 0x0; /* 1=standard, 0=extended */ 1030 config->standard_tcb = 0x0; /* 1=standard, 0=extended */
@@ -1369,21 +1369,21 @@ static int e100_phy_init(struct nic *nic)
1369 u16 bmcr, stat, id_lo, id_hi, cong; 1369 u16 bmcr, stat, id_lo, id_hi, cong;
1370 1370
1371 /* Discover phy addr by searching addrs in order {1,0,2,..., 31} */ 1371 /* Discover phy addr by searching addrs in order {1,0,2,..., 31} */
1372 for(addr = 0; addr < 32; addr++) { 1372 for (addr = 0; addr < 32; addr++) {
1373 nic->mii.phy_id = (addr == 0) ? 1 : (addr == 1) ? 0 : addr; 1373 nic->mii.phy_id = (addr == 0) ? 1 : (addr == 1) ? 0 : addr;
1374 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR); 1374 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR);
1375 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); 1375 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR);
1376 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); 1376 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR);
1377 if(!((bmcr == 0xFFFF) || ((stat == 0) && (bmcr == 0)))) 1377 if (!((bmcr == 0xFFFF) || ((stat == 0) && (bmcr == 0))))
1378 break; 1378 break;
1379 } 1379 }
1380 DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id); 1380 DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id);
1381 if(addr == 32) 1381 if (addr == 32)
1382 return -EAGAIN; 1382 return -EAGAIN;
1383 1383
1384 /* Selected the phy and isolate the rest */ 1384 /* Selected the phy and isolate the rest */
1385 for(addr = 0; addr < 32; addr++) { 1385 for (addr = 0; addr < 32; addr++) {
1386 if(addr != nic->mii.phy_id) { 1386 if (addr != nic->mii.phy_id) {
1387 mdio_write(netdev, addr, MII_BMCR, BMCR_ISOLATE); 1387 mdio_write(netdev, addr, MII_BMCR, BMCR_ISOLATE);
1388 } else { 1388 } else {
1389 bmcr = mdio_read(netdev, addr, MII_BMCR); 1389 bmcr = mdio_read(netdev, addr, MII_BMCR);
@@ -1400,7 +1400,7 @@ static int e100_phy_init(struct nic *nic)
1400 1400
1401 /* Handle National tx phys */ 1401 /* Handle National tx phys */
1402#define NCS_PHY_MODEL_MASK 0xFFF0FFFF 1402#define NCS_PHY_MODEL_MASK 0xFFF0FFFF
1403 if((nic->phy & NCS_PHY_MODEL_MASK) == phy_nsc_tx) { 1403 if ((nic->phy & NCS_PHY_MODEL_MASK) == phy_nsc_tx) {
1404 /* Disable congestion control */ 1404 /* Disable congestion control */
1405 cong = mdio_read(netdev, nic->mii.phy_id, MII_NSC_CONG); 1405 cong = mdio_read(netdev, nic->mii.phy_id, MII_NSC_CONG);
1406 cong |= NSC_CONG_TXREADY; 1406 cong |= NSC_CONG_TXREADY;
@@ -1408,7 +1408,7 @@ static int e100_phy_init(struct nic *nic)
1408 mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong); 1408 mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong);
1409 } 1409 }
1410 1410
1411 if((nic->mac >= mac_82550_D102) || ((nic->flags & ich) && 1411 if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) &&
1412 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) && 1412 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) &&
1413 !(nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) { 1413 !(nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) {
1414 /* enable/disable MDI/MDI-X auto-switching. */ 1414 /* enable/disable MDI/MDI-X auto-switching. */
@@ -1426,25 +1426,25 @@ static int e100_hw_init(struct nic *nic)
1426 e100_hw_reset(nic); 1426 e100_hw_reset(nic);
1427 1427
1428 DPRINTK(HW, ERR, "e100_hw_init\n"); 1428 DPRINTK(HW, ERR, "e100_hw_init\n");
1429 if(!in_interrupt() && (err = e100_self_test(nic))) 1429 if (!in_interrupt() && (err = e100_self_test(nic)))
1430 return err; 1430 return err;
1431 1431
1432 if((err = e100_phy_init(nic))) 1432 if ((err = e100_phy_init(nic)))
1433 return err; 1433 return err;
1434 if((err = e100_exec_cmd(nic, cuc_load_base, 0))) 1434 if ((err = e100_exec_cmd(nic, cuc_load_base, 0)))
1435 return err; 1435 return err;
1436 if((err = e100_exec_cmd(nic, ruc_load_base, 0))) 1436 if ((err = e100_exec_cmd(nic, ruc_load_base, 0)))
1437 return err; 1437 return err;
1438 if ((err = e100_exec_cb_wait(nic, NULL, e100_setup_ucode))) 1438 if ((err = e100_exec_cb_wait(nic, NULL, e100_setup_ucode)))
1439 return err; 1439 return err;
1440 if((err = e100_exec_cb(nic, NULL, e100_configure))) 1440 if ((err = e100_exec_cb(nic, NULL, e100_configure)))
1441 return err; 1441 return err;
1442 if((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr))) 1442 if ((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr)))
1443 return err; 1443 return err;
1444 if((err = e100_exec_cmd(nic, cuc_dump_addr, 1444 if ((err = e100_exec_cmd(nic, cuc_dump_addr,
1445 nic->dma_addr + offsetof(struct mem, stats)))) 1445 nic->dma_addr + offsetof(struct mem, stats))))
1446 return err; 1446 return err;
1447 if((err = e100_exec_cmd(nic, cuc_dump_reset, 0))) 1447 if ((err = e100_exec_cmd(nic, cuc_dump_reset, 0)))
1448 return err; 1448 return err;
1449 1449
1450 e100_disable_irq(nic); 1450 e100_disable_irq(nic);
@@ -1460,7 +1460,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1460 1460
1461 cb->command = cpu_to_le16(cb_multi); 1461 cb->command = cpu_to_le16(cb_multi);
1462 cb->u.multi.count = cpu_to_le16(count * ETH_ALEN); 1462 cb->u.multi.count = cpu_to_le16(count * ETH_ALEN);
1463 for(i = 0; list && i < count; i++, list = list->next) 1463 for (i = 0; list && i < count; i++, list = list->next)
1464 memcpy(&cb->u.multi.addr[i*ETH_ALEN], &list->dmi_addr, 1464 memcpy(&cb->u.multi.addr[i*ETH_ALEN], &list->dmi_addr,
1465 ETH_ALEN); 1465 ETH_ALEN);
1466} 1466}
@@ -1472,12 +1472,12 @@ static void e100_set_multicast_list(struct net_device *netdev)
1472 DPRINTK(HW, DEBUG, "mc_count=%d, flags=0x%04X\n", 1472 DPRINTK(HW, DEBUG, "mc_count=%d, flags=0x%04X\n",
1473 netdev->mc_count, netdev->flags); 1473 netdev->mc_count, netdev->flags);
1474 1474
1475 if(netdev->flags & IFF_PROMISC) 1475 if (netdev->flags & IFF_PROMISC)
1476 nic->flags |= promiscuous; 1476 nic->flags |= promiscuous;
1477 else 1477 else
1478 nic->flags &= ~promiscuous; 1478 nic->flags &= ~promiscuous;
1479 1479
1480 if(netdev->flags & IFF_ALLMULTI || 1480 if (netdev->flags & IFF_ALLMULTI ||
1481 netdev->mc_count > E100_MAX_MULTICAST_ADDRS) 1481 netdev->mc_count > E100_MAX_MULTICAST_ADDRS)
1482 nic->flags |= multicast_all; 1482 nic->flags |= multicast_all;
1483 else 1483 else
@@ -1500,7 +1500,7 @@ static void e100_update_stats(struct nic *nic)
1500 * complete, so we're always waiting for results of the 1500 * complete, so we're always waiting for results of the
1501 * previous command. */ 1501 * previous command. */
1502 1502
1503 if(*complete == cpu_to_le32(cuc_dump_reset_complete)) { 1503 if (*complete == cpu_to_le32(cuc_dump_reset_complete)) {
1504 *complete = 0; 1504 *complete = 0;
1505 nic->tx_frames = le32_to_cpu(s->tx_good_frames); 1505 nic->tx_frames = le32_to_cpu(s->tx_good_frames);
1506 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions); 1506 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions);
@@ -1527,12 +1527,12 @@ static void e100_update_stats(struct nic *nic)
1527 le32_to_cpu(s->tx_single_collisions); 1527 le32_to_cpu(s->tx_single_collisions);
1528 nic->tx_multiple_collisions += 1528 nic->tx_multiple_collisions +=
1529 le32_to_cpu(s->tx_multiple_collisions); 1529 le32_to_cpu(s->tx_multiple_collisions);
1530 if(nic->mac >= mac_82558_D101_A4) { 1530 if (nic->mac >= mac_82558_D101_A4) {
1531 nic->tx_fc_pause += le32_to_cpu(s->fc_xmt_pause); 1531 nic->tx_fc_pause += le32_to_cpu(s->fc_xmt_pause);
1532 nic->rx_fc_pause += le32_to_cpu(s->fc_rcv_pause); 1532 nic->rx_fc_pause += le32_to_cpu(s->fc_rcv_pause);
1533 nic->rx_fc_unsupported += 1533 nic->rx_fc_unsupported +=
1534 le32_to_cpu(s->fc_rcv_unsupported); 1534 le32_to_cpu(s->fc_rcv_unsupported);
1535 if(nic->mac >= mac_82559_D101M) { 1535 if (nic->mac >= mac_82559_D101M) {
1536 nic->tx_tco_frames += 1536 nic->tx_tco_frames +=
1537 le16_to_cpu(s->xmt_tco_frames); 1537 le16_to_cpu(s->xmt_tco_frames);
1538 nic->rx_tco_frames += 1538 nic->rx_tco_frames +=
@@ -1542,7 +1542,7 @@ static void e100_update_stats(struct nic *nic)
1542 } 1542 }
1543 1543
1544 1544
1545 if(e100_exec_cmd(nic, cuc_dump_reset, 0)) 1545 if (e100_exec_cmd(nic, cuc_dump_reset, 0))
1546 DPRINTK(TX_ERR, DEBUG, "exec cuc_dump_reset failed\n"); 1546 DPRINTK(TX_ERR, DEBUG, "exec cuc_dump_reset failed\n");
1547} 1547}
1548 1548
@@ -1551,19 +1551,19 @@ static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
1551 /* Adjust inter-frame-spacing (IFS) between two transmits if 1551 /* Adjust inter-frame-spacing (IFS) between two transmits if
1552 * we're getting collisions on a half-duplex connection. */ 1552 * we're getting collisions on a half-duplex connection. */
1553 1553
1554 if(duplex == DUPLEX_HALF) { 1554 if (duplex == DUPLEX_HALF) {
1555 u32 prev = nic->adaptive_ifs; 1555 u32 prev = nic->adaptive_ifs;
1556 u32 min_frames = (speed == SPEED_100) ? 1000 : 100; 1556 u32 min_frames = (speed == SPEED_100) ? 1000 : 100;
1557 1557
1558 if((nic->tx_frames / 32 < nic->tx_collisions) && 1558 if ((nic->tx_frames / 32 < nic->tx_collisions) &&
1559 (nic->tx_frames > min_frames)) { 1559 (nic->tx_frames > min_frames)) {
1560 if(nic->adaptive_ifs < 60) 1560 if (nic->adaptive_ifs < 60)
1561 nic->adaptive_ifs += 5; 1561 nic->adaptive_ifs += 5;
1562 } else if (nic->tx_frames < min_frames) { 1562 } else if (nic->tx_frames < min_frames) {
1563 if(nic->adaptive_ifs >= 5) 1563 if (nic->adaptive_ifs >= 5)
1564 nic->adaptive_ifs -= 5; 1564 nic->adaptive_ifs -= 5;
1565 } 1565 }
1566 if(nic->adaptive_ifs != prev) 1566 if (nic->adaptive_ifs != prev)
1567 e100_exec_cb(nic, NULL, e100_configure); 1567 e100_exec_cb(nic, NULL, e100_configure);
1568 } 1568 }
1569} 1569}
@@ -1579,12 +1579,12 @@ static void e100_watchdog(unsigned long data)
1579 1579
1580 mii_ethtool_gset(&nic->mii, &cmd); 1580 mii_ethtool_gset(&nic->mii, &cmd);
1581 1581
1582 if(mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) { 1582 if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) {
1583 printk(KERN_INFO "e100: %s NIC Link is Up %s Mbps %s Duplex\n", 1583 printk(KERN_INFO "e100: %s NIC Link is Up %s Mbps %s Duplex\n",
1584 nic->netdev->name, 1584 nic->netdev->name,
1585 cmd.speed == SPEED_100 ? "100" : "10", 1585 cmd.speed == SPEED_100 ? "100" : "10",
1586 cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); 1586 cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
1587 } else if(!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { 1587 } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) {
1588 printk(KERN_INFO "e100: %s NIC Link is Down\n", 1588 printk(KERN_INFO "e100: %s NIC Link is Down\n",
1589 nic->netdev->name); 1589 nic->netdev->name);
1590 } 1590 }
@@ -1604,11 +1604,11 @@ static void e100_watchdog(unsigned long data)
1604 e100_update_stats(nic); 1604 e100_update_stats(nic);
1605 e100_adjust_adaptive_ifs(nic, cmd.speed, cmd.duplex); 1605 e100_adjust_adaptive_ifs(nic, cmd.speed, cmd.duplex);
1606 1606
1607 if(nic->mac <= mac_82557_D100_C) 1607 if (nic->mac <= mac_82557_D100_C)
1608 /* Issue a multicast command to workaround a 557 lock up */ 1608 /* Issue a multicast command to workaround a 557 lock up */
1609 e100_set_multicast_list(nic->netdev); 1609 e100_set_multicast_list(nic->netdev);
1610 1610
1611 if(nic->flags & ich && cmd.speed==SPEED_10 && cmd.duplex==DUPLEX_HALF) 1611 if (nic->flags & ich && cmd.speed==SPEED_10 && cmd.duplex==DUPLEX_HALF)
1612 /* Need SW workaround for ICH[x] 10Mbps/half duplex Tx hang. */ 1612 /* Need SW workaround for ICH[x] 10Mbps/half duplex Tx hang. */
1613 nic->flags |= ich_10h_workaround; 1613 nic->flags |= ich_10h_workaround;
1614 else 1614 else
@@ -1623,7 +1623,7 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
1623{ 1623{
1624 cb->command = nic->tx_command; 1624 cb->command = nic->tx_command;
1625 /* interrupt every 16 packets regardless of delay */ 1625 /* interrupt every 16 packets regardless of delay */
1626 if((nic->cbs_avail & ~15) == nic->cbs_avail) 1626 if ((nic->cbs_avail & ~15) == nic->cbs_avail)
1627 cb->command |= cpu_to_le16(cb_i); 1627 cb->command |= cpu_to_le16(cb_i);
1628 cb->u.tcb.tbd_array = cb->dma_addr + offsetof(struct cb, u.tcb.tbd); 1628 cb->u.tcb.tbd_array = cb->dma_addr + offsetof(struct cb, u.tcb.tbd);
1629 cb->u.tcb.tcb_byte_count = 0; 1629 cb->u.tcb.tcb_byte_count = 0;
@@ -1640,18 +1640,18 @@ static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1640 struct nic *nic = netdev_priv(netdev); 1640 struct nic *nic = netdev_priv(netdev);
1641 int err; 1641 int err;
1642 1642
1643 if(nic->flags & ich_10h_workaround) { 1643 if (nic->flags & ich_10h_workaround) {
1644 /* SW workaround for ICH[x] 10Mbps/half duplex Tx hang. 1644 /* SW workaround for ICH[x] 10Mbps/half duplex Tx hang.
1645 Issue a NOP command followed by a 1us delay before 1645 Issue a NOP command followed by a 1us delay before
1646 issuing the Tx command. */ 1646 issuing the Tx command. */
1647 if(e100_exec_cmd(nic, cuc_nop, 0)) 1647 if (e100_exec_cmd(nic, cuc_nop, 0))
1648 DPRINTK(TX_ERR, DEBUG, "exec cuc_nop failed\n"); 1648 DPRINTK(TX_ERR, DEBUG, "exec cuc_nop failed\n");
1649 udelay(1); 1649 udelay(1);
1650 } 1650 }
1651 1651
1652 err = e100_exec_cb(nic, skb, e100_xmit_prepare); 1652 err = e100_exec_cb(nic, skb, e100_xmit_prepare);
1653 1653
1654 switch(err) { 1654 switch (err) {
1655 case -ENOSPC: 1655 case -ENOSPC:
1656 /* We queued the skb, but now we're out of space. */ 1656 /* We queued the skb, but now we're out of space. */
1657 DPRINTK(TX_ERR, DEBUG, "No space for CB\n"); 1657 DPRINTK(TX_ERR, DEBUG, "No space for CB\n");
@@ -1677,14 +1677,14 @@ static int e100_tx_clean(struct nic *nic)
1677 spin_lock(&nic->cb_lock); 1677 spin_lock(&nic->cb_lock);
1678 1678
1679 /* Clean CBs marked complete */ 1679 /* Clean CBs marked complete */
1680 for(cb = nic->cb_to_clean; 1680 for (cb = nic->cb_to_clean;
1681 cb->status & cpu_to_le16(cb_complete); 1681 cb->status & cpu_to_le16(cb_complete);
1682 cb = nic->cb_to_clean = cb->next) { 1682 cb = nic->cb_to_clean = cb->next) {
1683 DPRINTK(TX_DONE, DEBUG, "cb[%d]->status = 0x%04X\n", 1683 DPRINTK(TX_DONE, DEBUG, "cb[%d]->status = 0x%04X\n",
1684 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), 1684 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)),
1685 cb->status); 1685 cb->status);
1686 1686
1687 if(likely(cb->skb != NULL)) { 1687 if (likely(cb->skb != NULL)) {
1688 dev->stats.tx_packets++; 1688 dev->stats.tx_packets++;
1689 dev->stats.tx_bytes += cb->skb->len; 1689 dev->stats.tx_bytes += cb->skb->len;
1690 1690
@@ -1703,7 +1703,7 @@ static int e100_tx_clean(struct nic *nic)
1703 spin_unlock(&nic->cb_lock); 1703 spin_unlock(&nic->cb_lock);
1704 1704
1705 /* Recover from running out of Tx resources in xmit_frame */ 1705 /* Recover from running out of Tx resources in xmit_frame */
1706 if(unlikely(tx_cleaned && netif_queue_stopped(nic->netdev))) 1706 if (unlikely(tx_cleaned && netif_queue_stopped(nic->netdev)))
1707 netif_wake_queue(nic->netdev); 1707 netif_wake_queue(nic->netdev);
1708 1708
1709 return tx_cleaned; 1709 return tx_cleaned;
@@ -1711,10 +1711,10 @@ static int e100_tx_clean(struct nic *nic)
1711 1711
1712static void e100_clean_cbs(struct nic *nic) 1712static void e100_clean_cbs(struct nic *nic)
1713{ 1713{
1714 if(nic->cbs) { 1714 if (nic->cbs) {
1715 while(nic->cbs_avail != nic->params.cbs.count) { 1715 while (nic->cbs_avail != nic->params.cbs.count) {
1716 struct cb *cb = nic->cb_to_clean; 1716 struct cb *cb = nic->cb_to_clean;
1717 if(cb->skb) { 1717 if (cb->skb) {
1718 pci_unmap_single(nic->pdev, 1718 pci_unmap_single(nic->pdev,
1719 le32_to_cpu(cb->u.tcb.tbd.buf_addr), 1719 le32_to_cpu(cb->u.tcb.tbd.buf_addr),
1720 le16_to_cpu(cb->u.tcb.tbd.size), 1720 le16_to_cpu(cb->u.tcb.tbd.size),
@@ -1746,10 +1746,10 @@ static int e100_alloc_cbs(struct nic *nic)
1746 1746
1747 nic->cbs = pci_alloc_consistent(nic->pdev, 1747 nic->cbs = pci_alloc_consistent(nic->pdev,
1748 sizeof(struct cb) * count, &nic->cbs_dma_addr); 1748 sizeof(struct cb) * count, &nic->cbs_dma_addr);
1749 if(!nic->cbs) 1749 if (!nic->cbs)
1750 return -ENOMEM; 1750 return -ENOMEM;
1751 1751
1752 for(cb = nic->cbs, i = 0; i < count; cb++, i++) { 1752 for (cb = nic->cbs, i = 0; i < count; cb++, i++) {
1753 cb->next = (i + 1 < count) ? cb + 1 : nic->cbs; 1753 cb->next = (i + 1 < count) ? cb + 1 : nic->cbs;
1754 cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1; 1754 cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1;
1755 1755
@@ -1767,14 +1767,14 @@ static int e100_alloc_cbs(struct nic *nic)
1767 1767
1768static inline void e100_start_receiver(struct nic *nic, struct rx *rx) 1768static inline void e100_start_receiver(struct nic *nic, struct rx *rx)
1769{ 1769{
1770 if(!nic->rxs) return; 1770 if (!nic->rxs) return;
1771 if(RU_SUSPENDED != nic->ru_running) return; 1771 if (RU_SUSPENDED != nic->ru_running) return;
1772 1772
1773 /* handle init time starts */ 1773 /* handle init time starts */
1774 if(!rx) rx = nic->rxs; 1774 if (!rx) rx = nic->rxs;
1775 1775
1776 /* (Re)start RU if suspended or idle and RFA is non-NULL */ 1776 /* (Re)start RU if suspended or idle and RFA is non-NULL */
1777 if(rx->skb) { 1777 if (rx->skb) {
1778 e100_exec_cmd(nic, ruc_start, rx->dma_addr); 1778 e100_exec_cmd(nic, ruc_start, rx->dma_addr);
1779 nic->ru_running = RU_RUNNING; 1779 nic->ru_running = RU_RUNNING;
1780 } 1780 }
@@ -1783,7 +1783,7 @@ static inline void e100_start_receiver(struct nic *nic, struct rx *rx)
1783#define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN) 1783#define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN)
1784static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) 1784static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1785{ 1785{
1786 if(!(rx->skb = netdev_alloc_skb(nic->netdev, RFD_BUF_LEN + NET_IP_ALIGN))) 1786 if (!(rx->skb = netdev_alloc_skb(nic->netdev, RFD_BUF_LEN + NET_IP_ALIGN)))
1787 return -ENOMEM; 1787 return -ENOMEM;
1788 1788
1789 /* Align, init, and map the RFD. */ 1789 /* Align, init, and map the RFD. */
@@ -1820,7 +1820,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1820 struct rfd *rfd = (struct rfd *)skb->data; 1820 struct rfd *rfd = (struct rfd *)skb->data;
1821 u16 rfd_status, actual_size; 1821 u16 rfd_status, actual_size;
1822 1822
1823 if(unlikely(work_done && *work_done >= work_to_do)) 1823 if (unlikely(work_done && *work_done >= work_to_do))
1824 return -EAGAIN; 1824 return -EAGAIN;
1825 1825
1826 /* Need to sync before taking a peek at cb_complete bit */ 1826 /* Need to sync before taking a peek at cb_complete bit */
@@ -1847,7 +1847,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1847 1847
1848 /* Get actual data size */ 1848 /* Get actual data size */
1849 actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF; 1849 actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
1850 if(unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd))) 1850 if (unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd)))
1851 actual_size = RFD_BUF_LEN - sizeof(struct rfd); 1851 actual_size = RFD_BUF_LEN - sizeof(struct rfd);
1852 1852
1853 /* Get data */ 1853 /* Get data */
@@ -1872,10 +1872,10 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1872 skb_put(skb, actual_size); 1872 skb_put(skb, actual_size);
1873 skb->protocol = eth_type_trans(skb, nic->netdev); 1873 skb->protocol = eth_type_trans(skb, nic->netdev);
1874 1874
1875 if(unlikely(!(rfd_status & cb_ok))) { 1875 if (unlikely(!(rfd_status & cb_ok))) {
1876 /* Don't indicate if hardware indicates errors */ 1876 /* Don't indicate if hardware indicates errors */
1877 dev_kfree_skb_any(skb); 1877 dev_kfree_skb_any(skb);
1878 } else if(actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) { 1878 } else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) {
1879 /* Don't indicate oversized frames */ 1879 /* Don't indicate oversized frames */
1880 nic->rx_over_length_errors++; 1880 nic->rx_over_length_errors++;
1881 dev_kfree_skb_any(skb); 1881 dev_kfree_skb_any(skb);
@@ -1883,7 +1883,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1883 dev->stats.rx_packets++; 1883 dev->stats.rx_packets++;
1884 dev->stats.rx_bytes += actual_size; 1884 dev->stats.rx_bytes += actual_size;
1885 netif_receive_skb(skb); 1885 netif_receive_skb(skb);
1886 if(work_done) 1886 if (work_done)
1887 (*work_done)++; 1887 (*work_done)++;
1888 } 1888 }
1889 1889
@@ -1901,7 +1901,7 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1901 struct rfd *old_before_last_rfd, *new_before_last_rfd; 1901 struct rfd *old_before_last_rfd, *new_before_last_rfd;
1902 1902
1903 /* Indicate newly arrived packets */ 1903 /* Indicate newly arrived packets */
1904 for(rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) { 1904 for (rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) {
1905 err = e100_rx_indicate(nic, rx, work_done, work_to_do); 1905 err = e100_rx_indicate(nic, rx, work_done, work_to_do);
1906 /* Hit quota or no more to clean */ 1906 /* Hit quota or no more to clean */
1907 if (-EAGAIN == err || -ENODATA == err) 1907 if (-EAGAIN == err || -ENODATA == err)
@@ -1922,8 +1922,8 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1922 old_before_last_rfd = (struct rfd *)old_before_last_rx->skb->data; 1922 old_before_last_rfd = (struct rfd *)old_before_last_rx->skb->data;
1923 1923
1924 /* Alloc new skbs to refill list */ 1924 /* Alloc new skbs to refill list */
1925 for(rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) { 1925 for (rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) {
1926 if(unlikely(e100_rx_alloc_skb(nic, rx))) 1926 if (unlikely(e100_rx_alloc_skb(nic, rx)))
1927 break; /* Better luck next time (see watchdog) */ 1927 break; /* Better luck next time (see watchdog) */
1928 } 1928 }
1929 1929
@@ -1959,11 +1959,11 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1959 PCI_DMA_BIDIRECTIONAL); 1959 PCI_DMA_BIDIRECTIONAL);
1960 } 1960 }
1961 1961
1962 if(restart_required) { 1962 if (restart_required) {
1963 // ack the rnr? 1963 // ack the rnr?
1964 iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack); 1964 iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack);
1965 e100_start_receiver(nic, nic->rx_to_clean); 1965 e100_start_receiver(nic, nic->rx_to_clean);
1966 if(work_done) 1966 if (work_done)
1967 (*work_done)++; 1967 (*work_done)++;
1968 } 1968 }
1969} 1969}
@@ -1975,9 +1975,9 @@ static void e100_rx_clean_list(struct nic *nic)
1975 1975
1976 nic->ru_running = RU_UNINITIALIZED; 1976 nic->ru_running = RU_UNINITIALIZED;
1977 1977
1978 if(nic->rxs) { 1978 if (nic->rxs) {
1979 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 1979 for (rx = nic->rxs, i = 0; i < count; rx++, i++) {
1980 if(rx->skb) { 1980 if (rx->skb) {
1981 pci_unmap_single(nic->pdev, rx->dma_addr, 1981 pci_unmap_single(nic->pdev, rx->dma_addr,
1982 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 1982 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
1983 dev_kfree_skb(rx->skb); 1983 dev_kfree_skb(rx->skb);
@@ -1999,13 +1999,13 @@ static int e100_rx_alloc_list(struct nic *nic)
1999 nic->rx_to_use = nic->rx_to_clean = NULL; 1999 nic->rx_to_use = nic->rx_to_clean = NULL;
2000 nic->ru_running = RU_UNINITIALIZED; 2000 nic->ru_running = RU_UNINITIALIZED;
2001 2001
2002 if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC))) 2002 if (!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC)))
2003 return -ENOMEM; 2003 return -ENOMEM;
2004 2004
2005 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 2005 for (rx = nic->rxs, i = 0; i < count; rx++, i++) {
2006 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs; 2006 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs;
2007 rx->prev = (i == 0) ? nic->rxs + count - 1 : rx - 1; 2007 rx->prev = (i == 0) ? nic->rxs + count - 1 : rx - 1;
2008 if(e100_rx_alloc_skb(nic, rx)) { 2008 if (e100_rx_alloc_skb(nic, rx)) {
2009 e100_rx_clean_list(nic); 2009 e100_rx_clean_list(nic);
2010 return -ENOMEM; 2010 return -ENOMEM;
2011 } 2011 }
@@ -2038,7 +2038,7 @@ static irqreturn_t e100_intr(int irq, void *dev_id)
2038 2038
2039 DPRINTK(INTR, DEBUG, "stat_ack = 0x%02X\n", stat_ack); 2039 DPRINTK(INTR, DEBUG, "stat_ack = 0x%02X\n", stat_ack);
2040 2040
2041 if(stat_ack == stat_ack_not_ours || /* Not our interrupt */ 2041 if (stat_ack == stat_ack_not_ours || /* Not our interrupt */
2042 stat_ack == stat_ack_not_present) /* Hardware is ejected */ 2042 stat_ack == stat_ack_not_present) /* Hardware is ejected */
2043 return IRQ_NONE; 2043 return IRQ_NONE;
2044 2044
@@ -2046,10 +2046,10 @@ static irqreturn_t e100_intr(int irq, void *dev_id)
2046 iowrite8(stat_ack, &nic->csr->scb.stat_ack); 2046 iowrite8(stat_ack, &nic->csr->scb.stat_ack);
2047 2047
2048 /* We hit Receive No Resource (RNR); restart RU after cleaning */ 2048 /* We hit Receive No Resource (RNR); restart RU after cleaning */
2049 if(stat_ack & stat_ack_rnr) 2049 if (stat_ack & stat_ack_rnr)
2050 nic->ru_running = RU_SUSPENDED; 2050 nic->ru_running = RU_SUSPENDED;
2051 2051
2052 if(likely(netif_rx_schedule_prep(&nic->napi))) { 2052 if (likely(netif_rx_schedule_prep(&nic->napi))) {
2053 e100_disable_irq(nic); 2053 e100_disable_irq(nic);
2054 __netif_rx_schedule(&nic->napi); 2054 __netif_rx_schedule(&nic->napi);
2055 } 2055 }
@@ -2102,7 +2102,7 @@ static int e100_set_mac_address(struct net_device *netdev, void *p)
2102 2102
2103static int e100_change_mtu(struct net_device *netdev, int new_mtu) 2103static int e100_change_mtu(struct net_device *netdev, int new_mtu)
2104{ 2104{
2105 if(new_mtu < ETH_ZLEN || new_mtu > ETH_DATA_LEN) 2105 if (new_mtu < ETH_ZLEN || new_mtu > ETH_DATA_LEN)
2106 return -EINVAL; 2106 return -EINVAL;
2107 netdev->mtu = new_mtu; 2107 netdev->mtu = new_mtu;
2108 return 0; 2108 return 0;
@@ -2121,16 +2121,16 @@ static int e100_up(struct nic *nic)
2121{ 2121{
2122 int err; 2122 int err;
2123 2123
2124 if((err = e100_rx_alloc_list(nic))) 2124 if ((err = e100_rx_alloc_list(nic)))
2125 return err; 2125 return err;
2126 if((err = e100_alloc_cbs(nic))) 2126 if ((err = e100_alloc_cbs(nic)))
2127 goto err_rx_clean_list; 2127 goto err_rx_clean_list;
2128 if((err = e100_hw_init(nic))) 2128 if ((err = e100_hw_init(nic)))
2129 goto err_clean_cbs; 2129 goto err_clean_cbs;
2130 e100_set_multicast_list(nic->netdev); 2130 e100_set_multicast_list(nic->netdev);
2131 e100_start_receiver(nic, NULL); 2131 e100_start_receiver(nic, NULL);
2132 mod_timer(&nic->watchdog, jiffies); 2132 mod_timer(&nic->watchdog, jiffies);
2133 if((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED, 2133 if ((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED,
2134 nic->netdev->name, nic->netdev))) 2134 nic->netdev->name, nic->netdev)))
2135 goto err_no_irq; 2135 goto err_no_irq;
2136 netif_wake_queue(nic->netdev); 2136 netif_wake_queue(nic->netdev);
@@ -2192,26 +2192,26 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
2192 * in loopback mode, and the test passes if the received 2192 * in loopback mode, and the test passes if the received
2193 * packet compares byte-for-byte to the transmitted packet. */ 2193 * packet compares byte-for-byte to the transmitted packet. */
2194 2194
2195 if((err = e100_rx_alloc_list(nic))) 2195 if ((err = e100_rx_alloc_list(nic)))
2196 return err; 2196 return err;
2197 if((err = e100_alloc_cbs(nic))) 2197 if ((err = e100_alloc_cbs(nic)))
2198 goto err_clean_rx; 2198 goto err_clean_rx;
2199 2199
2200 /* ICH PHY loopback is broken so do MAC loopback instead */ 2200 /* ICH PHY loopback is broken so do MAC loopback instead */
2201 if(nic->flags & ich && loopback_mode == lb_phy) 2201 if (nic->flags & ich && loopback_mode == lb_phy)
2202 loopback_mode = lb_mac; 2202 loopback_mode = lb_mac;
2203 2203
2204 nic->loopback = loopback_mode; 2204 nic->loopback = loopback_mode;
2205 if((err = e100_hw_init(nic))) 2205 if ((err = e100_hw_init(nic)))
2206 goto err_loopback_none; 2206 goto err_loopback_none;
2207 2207
2208 if(loopback_mode == lb_phy) 2208 if (loopback_mode == lb_phy)
2209 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 2209 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR,
2210 BMCR_LOOPBACK); 2210 BMCR_LOOPBACK);
2211 2211
2212 e100_start_receiver(nic, NULL); 2212 e100_start_receiver(nic, NULL);
2213 2213
2214 if(!(skb = netdev_alloc_skb(nic->netdev, ETH_DATA_LEN))) { 2214 if (!(skb = netdev_alloc_skb(nic->netdev, ETH_DATA_LEN))) {
2215 err = -ENOMEM; 2215 err = -ENOMEM;
2216 goto err_loopback_none; 2216 goto err_loopback_none;
2217 } 2217 }
@@ -2224,7 +2224,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, 2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr,
2225 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 2225 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
2226 2226
2227 if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), 2227 if (memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd),
2228 skb->data, ETH_DATA_LEN)) 2228 skb->data, ETH_DATA_LEN))
2229 err = -EAGAIN; 2229 err = -EAGAIN;
2230 2230
@@ -2301,7 +2301,7 @@ static void e100_get_regs(struct net_device *netdev,
2301 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 | 2301 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 |
2302 ioread8(&nic->csr->scb.cmd_lo) << 16 | 2302 ioread8(&nic->csr->scb.cmd_lo) << 16 |
2303 ioread16(&nic->csr->scb.status); 2303 ioread16(&nic->csr->scb.status);
2304 for(i = E100_PHY_REGS; i >= 0; i--) 2304 for (i = E100_PHY_REGS; i >= 0; i--)
2305 buff[1 + E100_PHY_REGS - i] = 2305 buff[1 + E100_PHY_REGS - i] =
2306 mdio_read(netdev, nic->mii.phy_id, i); 2306 mdio_read(netdev, nic->mii.phy_id, i);
2307 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf)); 2307 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf));
@@ -2326,7 +2326,7 @@ static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
2326 !device_can_wakeup(&nic->pdev->dev)) 2326 !device_can_wakeup(&nic->pdev->dev))
2327 return -EOPNOTSUPP; 2327 return -EOPNOTSUPP;
2328 2328
2329 if(wol->wolopts) 2329 if (wol->wolopts)
2330 nic->flags |= wol_magic; 2330 nic->flags |= wol_magic;
2331 else 2331 else
2332 nic->flags &= ~wol_magic; 2332 nic->flags &= ~wol_magic;
@@ -2385,7 +2385,7 @@ static int e100_set_eeprom(struct net_device *netdev,
2385{ 2385{
2386 struct nic *nic = netdev_priv(netdev); 2386 struct nic *nic = netdev_priv(netdev);
2387 2387
2388 if(eeprom->magic != E100_EEPROM_MAGIC) 2388 if (eeprom->magic != E100_EEPROM_MAGIC)
2389 return -EINVAL; 2389 return -EINVAL;
2390 2390
2391 memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len); 2391 memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len);
@@ -2421,7 +2421,7 @@ static int e100_set_ringparam(struct net_device *netdev,
2421 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 2421 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
2422 return -EINVAL; 2422 return -EINVAL;
2423 2423
2424 if(netif_running(netdev)) 2424 if (netif_running(netdev))
2425 e100_down(nic); 2425 e100_down(nic);
2426 rfds->count = max(ring->rx_pending, rfds->min); 2426 rfds->count = max(ring->rx_pending, rfds->min);
2427 rfds->count = min(rfds->count, rfds->max); 2427 rfds->count = min(rfds->count, rfds->max);
@@ -2429,7 +2429,7 @@ static int e100_set_ringparam(struct net_device *netdev,
2429 cbs->count = min(cbs->count, cbs->max); 2429 cbs->count = min(cbs->count, cbs->max);
2430 DPRINTK(DRV, INFO, "Ring Param settings: rx: %d, tx %d\n", 2430 DPRINTK(DRV, INFO, "Ring Param settings: rx: %d, tx %d\n",
2431 rfds->count, cbs->count); 2431 rfds->count, cbs->count);
2432 if(netif_running(netdev)) 2432 if (netif_running(netdev))
2433 e100_up(nic); 2433 e100_up(nic);
2434 2434
2435 return 0; 2435 return 0;
@@ -2454,12 +2454,12 @@ static void e100_diag_test(struct net_device *netdev,
2454 memset(data, 0, E100_TEST_LEN * sizeof(u64)); 2454 memset(data, 0, E100_TEST_LEN * sizeof(u64));
2455 data[0] = !mii_link_ok(&nic->mii); 2455 data[0] = !mii_link_ok(&nic->mii);
2456 data[1] = e100_eeprom_load(nic); 2456 data[1] = e100_eeprom_load(nic);
2457 if(test->flags & ETH_TEST_FL_OFFLINE) { 2457 if (test->flags & ETH_TEST_FL_OFFLINE) {
2458 2458
2459 /* save speed, duplex & autoneg settings */ 2459 /* save speed, duplex & autoneg settings */
2460 err = mii_ethtool_gset(&nic->mii, &cmd); 2460 err = mii_ethtool_gset(&nic->mii, &cmd);
2461 2461
2462 if(netif_running(netdev)) 2462 if (netif_running(netdev))
2463 e100_down(nic); 2463 e100_down(nic);
2464 data[2] = e100_self_test(nic); 2464 data[2] = e100_self_test(nic);
2465 data[3] = e100_loopback_test(nic, lb_mac); 2465 data[3] = e100_loopback_test(nic, lb_mac);
@@ -2468,10 +2468,10 @@ static void e100_diag_test(struct net_device *netdev,
2468 /* restore speed, duplex & autoneg settings */ 2468 /* restore speed, duplex & autoneg settings */
2469 err = mii_ethtool_sset(&nic->mii, &cmd); 2469 err = mii_ethtool_sset(&nic->mii, &cmd);
2470 2470
2471 if(netif_running(netdev)) 2471 if (netif_running(netdev))
2472 e100_up(nic); 2472 e100_up(nic);
2473 } 2473 }
2474 for(i = 0; i < E100_TEST_LEN; i++) 2474 for (i = 0; i < E100_TEST_LEN; i++)
2475 test->flags |= data[i] ? ETH_TEST_FL_FAILED : 0; 2475 test->flags |= data[i] ? ETH_TEST_FL_FAILED : 0;
2476 2476
2477 msleep_interruptible(4 * 1000); 2477 msleep_interruptible(4 * 1000);
@@ -2481,7 +2481,7 @@ static int e100_phys_id(struct net_device *netdev, u32 data)
2481{ 2481{
2482 struct nic *nic = netdev_priv(netdev); 2482 struct nic *nic = netdev_priv(netdev);
2483 2483
2484 if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) 2484 if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
2485 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); 2485 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
2486 mod_timer(&nic->blink_timer, jiffies); 2486 mod_timer(&nic->blink_timer, jiffies);
2487 msleep_interruptible(data * 1000); 2487 msleep_interruptible(data * 1000);
@@ -2524,7 +2524,7 @@ static void e100_get_ethtool_stats(struct net_device *netdev,
2524 struct nic *nic = netdev_priv(netdev); 2524 struct nic *nic = netdev_priv(netdev);
2525 int i; 2525 int i;
2526 2526
2527 for(i = 0; i < E100_NET_STATS_LEN; i++) 2527 for (i = 0; i < E100_NET_STATS_LEN; i++)
2528 data[i] = ((unsigned long *)&netdev->stats)[i]; 2528 data[i] = ((unsigned long *)&netdev->stats)[i];
2529 2529
2530 data[i++] = nic->tx_deferred; 2530 data[i++] = nic->tx_deferred;
@@ -2539,7 +2539,7 @@ static void e100_get_ethtool_stats(struct net_device *netdev,
2539 2539
2540static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data) 2540static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
2541{ 2541{
2542 switch(stringset) { 2542 switch (stringset) {
2543 case ETH_SS_TEST: 2543 case ETH_SS_TEST:
2544 memcpy(data, *e100_gstrings_test, sizeof(e100_gstrings_test)); 2544 memcpy(data, *e100_gstrings_test, sizeof(e100_gstrings_test));
2545 break; 2545 break;
@@ -2589,7 +2589,7 @@ static int e100_alloc(struct nic *nic)
2589 2589
2590static void e100_free(struct nic *nic) 2590static void e100_free(struct nic *nic)
2591{ 2591{
2592 if(nic->mem) { 2592 if (nic->mem) {
2593 pci_free_consistent(nic->pdev, sizeof(struct mem), 2593 pci_free_consistent(nic->pdev, sizeof(struct mem),
2594 nic->mem, nic->dma_addr); 2594 nic->mem, nic->dma_addr);
2595 nic->mem = NULL; 2595 nic->mem = NULL;
@@ -2602,7 +2602,7 @@ static int e100_open(struct net_device *netdev)
2602 int err = 0; 2602 int err = 0;
2603 2603
2604 netif_carrier_off(netdev); 2604 netif_carrier_off(netdev);
2605 if((err = e100_up(nic))) 2605 if ((err = e100_up(nic)))
2606 DPRINTK(IFUP, ERR, "Cannot open interface, aborting.\n"); 2606 DPRINTK(IFUP, ERR, "Cannot open interface, aborting.\n");
2607 return err; 2607 return err;
2608} 2608}
@@ -2635,8 +2635,8 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2635 struct nic *nic; 2635 struct nic *nic;
2636 int err; 2636 int err;
2637 2637
2638 if(!(netdev = alloc_etherdev(sizeof(struct nic)))) { 2638 if (!(netdev = alloc_etherdev(sizeof(struct nic)))) {
2639 if(((1 << debug) - 1) & NETIF_MSG_PROBE) 2639 if (((1 << debug) - 1) & NETIF_MSG_PROBE)
2640 printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n"); 2640 printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n");
2641 return -ENOMEM; 2641 return -ENOMEM;
2642 } 2642 }
@@ -2653,24 +2653,24 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2653 nic->msg_enable = (1 << debug) - 1; 2653 nic->msg_enable = (1 << debug) - 1;
2654 pci_set_drvdata(pdev, netdev); 2654 pci_set_drvdata(pdev, netdev);
2655 2655
2656 if((err = pci_enable_device(pdev))) { 2656 if ((err = pci_enable_device(pdev))) {
2657 DPRINTK(PROBE, ERR, "Cannot enable PCI device, aborting.\n"); 2657 DPRINTK(PROBE, ERR, "Cannot enable PCI device, aborting.\n");
2658 goto err_out_free_dev; 2658 goto err_out_free_dev;
2659 } 2659 }
2660 2660
2661 if(!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 2661 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
2662 DPRINTK(PROBE, ERR, "Cannot find proper PCI device " 2662 DPRINTK(PROBE, ERR, "Cannot find proper PCI device "
2663 "base address, aborting.\n"); 2663 "base address, aborting.\n");
2664 err = -ENODEV; 2664 err = -ENODEV;
2665 goto err_out_disable_pdev; 2665 goto err_out_disable_pdev;
2666 } 2666 }
2667 2667
2668 if((err = pci_request_regions(pdev, DRV_NAME))) { 2668 if ((err = pci_request_regions(pdev, DRV_NAME))) {
2669 DPRINTK(PROBE, ERR, "Cannot obtain PCI resources, aborting.\n"); 2669 DPRINTK(PROBE, ERR, "Cannot obtain PCI resources, aborting.\n");
2670 goto err_out_disable_pdev; 2670 goto err_out_disable_pdev;
2671 } 2671 }
2672 2672
2673 if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) { 2673 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
2674 DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n"); 2674 DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n");
2675 goto err_out_free_res; 2675 goto err_out_free_res;
2676 } 2676 }
@@ -2681,13 +2681,13 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2681 DPRINTK(PROBE, INFO, "using i/o access mode\n"); 2681 DPRINTK(PROBE, INFO, "using i/o access mode\n");
2682 2682
2683 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr)); 2683 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr));
2684 if(!nic->csr) { 2684 if (!nic->csr) {
2685 DPRINTK(PROBE, ERR, "Cannot map device registers, aborting.\n"); 2685 DPRINTK(PROBE, ERR, "Cannot map device registers, aborting.\n");
2686 err = -ENOMEM; 2686 err = -ENOMEM;
2687 goto err_out_free_res; 2687 goto err_out_free_res;
2688 } 2688 }
2689 2689
2690 if(ent->driver_data) 2690 if (ent->driver_data)
2691 nic->flags |= ich; 2691 nic->flags |= ich;
2692 else 2692 else
2693 nic->flags &= ~ich; 2693 nic->flags &= ~ich;
@@ -2715,12 +2715,12 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2715 2715
2716 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task); 2716 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
2717 2717
2718 if((err = e100_alloc(nic))) { 2718 if ((err = e100_alloc(nic))) {
2719 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n"); 2719 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
2720 goto err_out_iounmap; 2720 goto err_out_iounmap;
2721 } 2721 }
2722 2722
2723 if((err = e100_eeprom_load(nic))) 2723 if ((err = e100_eeprom_load(nic)))
2724 goto err_out_free; 2724 goto err_out_free;
2725 2725
2726 e100_phy_init(nic); 2726 e100_phy_init(nic);
@@ -2740,7 +2740,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2740 } 2740 }
2741 2741
2742 /* Wol magic packet can be enabled from eeprom */ 2742 /* Wol magic packet can be enabled from eeprom */
2743 if((nic->mac >= mac_82558_D101_A4) && 2743 if ((nic->mac >= mac_82558_D101_A4) &&
2744 (nic->eeprom[eeprom_id] & eeprom_id_wol)) { 2744 (nic->eeprom[eeprom_id] & eeprom_id_wol)) {
2745 nic->flags |= wol_magic; 2745 nic->flags |= wol_magic;
2746 device_set_wakeup_enable(&pdev->dev, true); 2746 device_set_wakeup_enable(&pdev->dev, true);
@@ -2750,7 +2750,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2750 pci_pme_active(pdev, false); 2750 pci_pme_active(pdev, false);
2751 2751
2752 strcpy(netdev->name, "eth%d"); 2752 strcpy(netdev->name, "eth%d");
2753 if((err = register_netdev(netdev))) { 2753 if ((err = register_netdev(netdev))) {
2754 DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n"); 2754 DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n");
2755 goto err_out_free; 2755 goto err_out_free;
2756 } 2756 }
@@ -2779,7 +2779,7 @@ static void __devexit e100_remove(struct pci_dev *pdev)
2779{ 2779{
2780 struct net_device *netdev = pci_get_drvdata(pdev); 2780 struct net_device *netdev = pci_get_drvdata(pdev);
2781 2781
2782 if(netdev) { 2782 if (netdev) {
2783 struct nic *nic = netdev_priv(netdev); 2783 struct nic *nic = netdev_priv(netdev);
2784 unregister_netdev(netdev); 2784 unregister_netdev(netdev);
2785 e100_free(nic); 2785 e100_free(nic);
@@ -2932,7 +2932,7 @@ static struct pci_driver e100_driver = {
2932 2932
2933static int __init e100_init_module(void) 2933static int __init e100_init_module(void)
2934{ 2934{
2935 if(((1 << debug) - 1) & NETIF_MSG_DRV) { 2935 if (((1 << debug) - 1) & NETIF_MSG_DRV) {
2936 printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION); 2936 printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
2937 printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT); 2937 printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT);
2938 } 2938 }
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 9930d5f8b9e1..6271b9411ccf 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -478,7 +478,7 @@ struct ehea_port {
478 int num_add_tx_qps; 478 int num_add_tx_qps;
479 int num_mcs; 479 int num_mcs;
480 int resets; 480 int resets;
481 u64 flags; 481 unsigned long flags;
482 u64 mac_addr; 482 u64 mac_addr;
483 u32 logical_port_id; 483 u32 logical_port_id;
484 u32 port_speed; 484 u32 port_speed;
@@ -510,7 +510,6 @@ void ehea_set_ethtool_ops(struct net_device *netdev);
510int ehea_sense_port_attr(struct ehea_port *port); 510int ehea_sense_port_attr(struct ehea_port *port);
511int ehea_set_portspeed(struct ehea_port *port, u32 port_speed); 511int ehea_set_portspeed(struct ehea_port *port, u32 port_speed);
512 512
513extern u64 ehea_driver_flags;
514extern struct work_struct ehea_rereg_mr_task; 513extern struct work_struct ehea_rereg_mr_task;
515 514
516#endif /* __EHEA_H__ */ 515#endif /* __EHEA_H__ */
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index a2f1905a23df..e3131ea629cd 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -99,7 +99,7 @@ MODULE_PARM_DESC(use_lro, " Large Receive Offload, 1: enable, 0: disable, "
99 99
100static int port_name_cnt; 100static int port_name_cnt;
101static LIST_HEAD(adapter_list); 101static LIST_HEAD(adapter_list);
102u64 ehea_driver_flags; 102static unsigned long ehea_driver_flags;
103struct work_struct ehea_rereg_mr_task; 103struct work_struct ehea_rereg_mr_task;
104static DEFINE_MUTEX(dlpar_mem_lock); 104static DEFINE_MUTEX(dlpar_mem_lock);
105struct ehea_fw_handle_array ehea_fw_handles; 105struct ehea_fw_handle_array ehea_fw_handles;
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index b0ef46c51a9d..cefe1d98f93e 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -944,7 +944,7 @@ static void enc28j60_hw_rx(struct net_device *ndev)
944 if (netif_msg_rx_status(priv)) 944 if (netif_msg_rx_status(priv))
945 enc28j60_dump_rsv(priv, __func__, next_packet, len, rxstat); 945 enc28j60_dump_rsv(priv, __func__, next_packet, len, rxstat);
946 946
947 if (!RSV_GETBIT(rxstat, RSV_RXOK)) { 947 if (!RSV_GETBIT(rxstat, RSV_RXOK) || len > MAX_FRAMELEN) {
948 if (netif_msg_rx_err(priv)) 948 if (netif_msg_rx_err(priv))
949 dev_err(&ndev->dev, "Rx Error (%04x)\n", rxstat); 949 dev_err(&ndev->dev, "Rx Error (%04x)\n", rxstat);
950 ndev->stats.rx_errors++; 950 ndev->stats.rx_errors++;
@@ -952,6 +952,8 @@ static void enc28j60_hw_rx(struct net_device *ndev)
952 ndev->stats.rx_crc_errors++; 952 ndev->stats.rx_crc_errors++;
953 if (RSV_GETBIT(rxstat, RSV_LENCHECKERR)) 953 if (RSV_GETBIT(rxstat, RSV_LENCHECKERR))
954 ndev->stats.rx_frame_errors++; 954 ndev->stats.rx_frame_errors++;
955 if (len > MAX_FRAMELEN)
956 ndev->stats.rx_over_errors++;
955 } else { 957 } else {
956 skb = dev_alloc_skb(len + NET_IP_ALIGN); 958 skb = dev_alloc_skb(len + NET_IP_ALIGN);
957 if (!skb) { 959 if (!skb) {
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 022794e579c7..b82b0fb2056c 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1457,8 +1457,8 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
1457 1457
1458 /* Number of supported queues. */ 1458 /* Number of supported queues. */
1459 /* Having more queues than CPUs doesn't make sense. */ 1459 /* Having more queues than CPUs doesn't make sense. */
1460 adapter->num_rx_queues = min((u32)IGB_MAX_RX_QUEUES, (u32)num_online_cpus()); 1460 adapter->num_rx_queues = min_t(u32, IGB_MAX_RX_QUEUES, num_online_cpus());
1461 adapter->num_tx_queues = min(IGB_MAX_TX_QUEUES, num_online_cpus()); 1461 adapter->num_tx_queues = min_t(u32, IGB_MAX_TX_QUEUES, num_online_cpus());
1462 1462
1463 /* This call may decrease the number of queues depending on 1463 /* This call may decrease the number of queues depending on
1464 * interrupt mode. */ 1464 * interrupt mode. */
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 5e70180bf569..6bb71b687f7b 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -75,7 +75,7 @@
75#include "myri10ge_mcp.h" 75#include "myri10ge_mcp.h"
76#include "myri10ge_mcp_gen_header.h" 76#include "myri10ge_mcp_gen_header.h"
77 77
78#define MYRI10GE_VERSION_STR "1.4.4-1.395" 78#define MYRI10GE_VERSION_STR "1.4.4-1.398"
79 79
80MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); 80MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
81MODULE_AUTHOR("Maintainer: help@myri.com"); 81MODULE_AUTHOR("Maintainer: help@myri.com");
@@ -3929,6 +3929,10 @@ abort_with_firmware:
3929 myri10ge_dummy_rdma(mgp, 0); 3929 myri10ge_dummy_rdma(mgp, 0);
3930 3930
3931abort_with_ioremap: 3931abort_with_ioremap:
3932 if (mgp->mac_addr_string != NULL)
3933 dev_err(&pdev->dev,
3934 "myri10ge_probe() failed: MAC=%s, SN=%ld\n",
3935 mgp->mac_addr_string, mgp->serial_number);
3932 iounmap(mgp->sram); 3936 iounmap(mgp->sram);
3933 3937
3934abort_with_mtrr: 3938abort_with_mtrr:
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index ba2e1c5b6bcf..459663a4023d 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -818,15 +818,6 @@ struct tx_doorbell_context {
818}; 818};
819 819
820/* DATA STRUCTURES SHARED WITH HARDWARE. */ 820/* DATA STRUCTURES SHARED WITH HARDWARE. */
821
822struct bq_element {
823 u32 addr_lo;
824#define BQ_END 0x00000001
825#define BQ_CONT 0x00000002
826#define BQ_MASK 0x00000003
827 u32 addr_hi;
828} __attribute((packed));
829
830struct tx_buf_desc { 821struct tx_buf_desc {
831 __le64 addr; 822 __le64 addr;
832 __le32 len; 823 __le32 len;
@@ -860,8 +851,8 @@ struct ob_mac_iocb_req {
860 __le16 frame_len; 851 __le16 frame_len;
861#define OB_MAC_IOCB_LEN_MASK 0x3ffff 852#define OB_MAC_IOCB_LEN_MASK 0x3ffff
862 __le16 reserved2; 853 __le16 reserved2;
863 __le32 tid; 854 u32 tid;
864 __le32 txq_idx; 855 u32 txq_idx;
865 __le32 reserved3; 856 __le32 reserved3;
866 __le16 vlan_tci; 857 __le16 vlan_tci;
867 __le16 reserved4; 858 __le16 reserved4;
@@ -880,8 +871,8 @@ struct ob_mac_iocb_rsp {
880 u8 flags2; /* */ 871 u8 flags2; /* */
881 u8 flags3; /* */ 872 u8 flags3; /* */
882#define OB_MAC_IOCB_RSP_B 0x80 /* */ 873#define OB_MAC_IOCB_RSP_B 0x80 /* */
883 __le32 tid; 874 u32 tid;
884 __le32 txq_idx; 875 u32 txq_idx;
885 __le32 reserved[13]; 876 __le32 reserved[13];
886} __attribute((packed)); 877} __attribute((packed));
887 878
@@ -903,8 +894,8 @@ struct ob_mac_tso_iocb_req {
903#define OB_MAC_TSO_IOCB_V 0x04 894#define OB_MAC_TSO_IOCB_V 0x04
904 __le32 reserved1[2]; 895 __le32 reserved1[2];
905 __le32 frame_len; 896 __le32 frame_len;
906 __le32 tid; 897 u32 tid;
907 __le32 txq_idx; 898 u32 txq_idx;
908 __le16 total_hdrs_len; 899 __le16 total_hdrs_len;
909 __le16 net_trans_offset; 900 __le16 net_trans_offset;
910#define OB_MAC_TRANSPORT_HDR_SHIFT 6 901#define OB_MAC_TRANSPORT_HDR_SHIFT 6
@@ -925,8 +916,8 @@ struct ob_mac_tso_iocb_rsp {
925 u8 flags2; /* */ 916 u8 flags2; /* */
926 u8 flags3; /* */ 917 u8 flags3; /* */
927#define OB_MAC_TSO_IOCB_RSP_B 0x8000 918#define OB_MAC_TSO_IOCB_RSP_B 0x8000
928 __le32 tid; 919 u32 tid;
929 __le32 txq_idx; 920 u32 txq_idx;
930 __le32 reserved2[13]; 921 __le32 reserved2[13];
931} __attribute((packed)); 922} __attribute((packed));
932 923
@@ -979,10 +970,11 @@ struct ib_mac_iocb_rsp {
979 970
980 __le16 reserved1; 971 __le16 reserved1;
981 __le32 reserved2[6]; 972 __le32 reserved2[6];
982 __le32 flags4; 973 u8 reserved3[3];
983#define IB_MAC_IOCB_RSP_HV 0x20000000 /* */ 974 u8 flags4;
984#define IB_MAC_IOCB_RSP_HS 0x40000000 /* */ 975#define IB_MAC_IOCB_RSP_HV 0x20
985#define IB_MAC_IOCB_RSP_HL 0x80000000 /* */ 976#define IB_MAC_IOCB_RSP_HS 0x40
977#define IB_MAC_IOCB_RSP_HL 0x80
986 __le32 hdr_len; /* */ 978 __le32 hdr_len; /* */
987 __le32 hdr_addr_lo; /* */ 979 __le32 hdr_addr_lo; /* */
988 __le32 hdr_addr_hi; /* */ 980 __le32 hdr_addr_hi; /* */
@@ -1126,7 +1118,7 @@ struct map_list {
1126struct tx_ring_desc { 1118struct tx_ring_desc {
1127 struct sk_buff *skb; 1119 struct sk_buff *skb;
1128 struct ob_mac_iocb_req *queue_entry; 1120 struct ob_mac_iocb_req *queue_entry;
1129 int index; 1121 u32 index;
1130 struct oal oal; 1122 struct oal oal;
1131 struct map_list map[MAX_SKB_FRAGS + 1]; 1123 struct map_list map[MAX_SKB_FRAGS + 1];
1132 int map_cnt; 1124 int map_cnt;
@@ -1138,8 +1130,8 @@ struct bq_desc {
1138 struct page *lbq_page; 1130 struct page *lbq_page;
1139 struct sk_buff *skb; 1131 struct sk_buff *skb;
1140 } p; 1132 } p;
1141 struct bq_element *bq; 1133 __le64 *addr;
1142 int index; 1134 u32 index;
1143 DECLARE_PCI_UNMAP_ADDR(mapaddr); 1135 DECLARE_PCI_UNMAP_ADDR(mapaddr);
1144 DECLARE_PCI_UNMAP_LEN(maplen); 1136 DECLARE_PCI_UNMAP_LEN(maplen);
1145}; 1137};
@@ -1189,7 +1181,7 @@ struct rx_ring {
1189 u32 cq_size; 1181 u32 cq_size;
1190 u32 cq_len; 1182 u32 cq_len;
1191 u16 cq_id; 1183 u16 cq_id;
1192 u32 *prod_idx_sh_reg; /* Shadowed producer register. */ 1184 volatile __le32 *prod_idx_sh_reg; /* Shadowed producer register. */
1193 dma_addr_t prod_idx_sh_reg_dma; 1185 dma_addr_t prod_idx_sh_reg_dma;
1194 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */ 1186 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */
1195 u32 cnsmr_idx; /* current sw idx */ 1187 u32 cnsmr_idx; /* current sw idx */
@@ -1467,21 +1459,6 @@ static inline void ql_write_db_reg(u32 val, void __iomem *addr)
1467 mmiowb(); 1459 mmiowb();
1468} 1460}
1469 1461
1470/*
1471 * Shadow Registers:
1472 * Outbound queues have a consumer index that is maintained by the chip.
1473 * Inbound queues have a producer index that is maintained by the chip.
1474 * For lower overhead, these registers are "shadowed" to host memory
1475 * which allows the device driver to track the queue progress without
1476 * PCI reads. When an entry is placed on an inbound queue, the chip will
1477 * update the relevant index register and then copy the value to the
1478 * shadow register in host memory.
1479 */
1480static inline unsigned int ql_read_sh_reg(const volatile void *addr)
1481{
1482 return *(volatile unsigned int __force *)addr;
1483}
1484
1485extern char qlge_driver_name[]; 1462extern char qlge_driver_name[];
1486extern const char qlge_driver_version[]; 1463extern const char qlge_driver_version[];
1487extern const struct ethtool_ops qlge_ethtool_ops; 1464extern const struct ethtool_ops qlge_ethtool_ops;
diff --git a/drivers/net/qlge/qlge_dbg.c b/drivers/net/qlge/qlge_dbg.c
index 47df304a02c8..3f5e02d2e4a9 100644
--- a/drivers/net/qlge/qlge_dbg.c
+++ b/drivers/net/qlge/qlge_dbg.c
@@ -821,14 +821,11 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
821 le16_to_cpu(ib_mac_rsp->vlan_id)); 821 le16_to_cpu(ib_mac_rsp->vlan_id));
822 822
823 printk(KERN_ERR PFX "flags4 = %s%s%s.\n", 823 printk(KERN_ERR PFX "flags4 = %s%s%s.\n",
824 le32_to_cpu(ib_mac_rsp-> 824 ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV ? "HV " : "",
825 flags4) & IB_MAC_IOCB_RSP_HV ? "HV " : "", 825 ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS ? "HS " : "",
826 le32_to_cpu(ib_mac_rsp-> 826 ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HL ? "HL " : "");
827 flags4) & IB_MAC_IOCB_RSP_HS ? "HS " : "", 827
828 le32_to_cpu(ib_mac_rsp-> 828 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
829 flags4) & IB_MAC_IOCB_RSP_HL ? "HL " : "");
830
831 if (le32_to_cpu(ib_mac_rsp->flags4) & IB_MAC_IOCB_RSP_HV) {
832 printk(KERN_ERR PFX "hdr length = %d.\n", 829 printk(KERN_ERR PFX "hdr length = %d.\n",
833 le32_to_cpu(ib_mac_rsp->hdr_len)); 830 le32_to_cpu(ib_mac_rsp->hdr_len));
834 printk(KERN_ERR PFX "hdr addr_hi = 0x%x.\n", 831 printk(KERN_ERR PFX "hdr addr_hi = 0x%x.\n",
diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c
index eefb81b13758..9d922e2ff226 100644
--- a/drivers/net/qlge/qlge_ethtool.c
+++ b/drivers/net/qlge/qlge_ethtool.c
@@ -56,9 +56,9 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
56 for (i = 1; i < qdev->rss_ring_first_cq_id; i++, rx_ring++) { 56 for (i = 1; i < qdev->rss_ring_first_cq_id; i++, rx_ring++) {
57 rx_ring = &qdev->rx_ring[i]; 57 rx_ring = &qdev->rx_ring[i];
58 cqicb = (struct cqicb *)rx_ring; 58 cqicb = (struct cqicb *)rx_ring;
59 cqicb->irq_delay = le16_to_cpu(qdev->tx_coalesce_usecs); 59 cqicb->irq_delay = cpu_to_le16(qdev->tx_coalesce_usecs);
60 cqicb->pkt_delay = 60 cqicb->pkt_delay =
61 le16_to_cpu(qdev->tx_max_coalesced_frames); 61 cpu_to_le16(qdev->tx_max_coalesced_frames);
62 cqicb->flags = FLAGS_LI; 62 cqicb->flags = FLAGS_LI;
63 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 63 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb),
64 CFG_LCQ, rx_ring->cq_id); 64 CFG_LCQ, rx_ring->cq_id);
@@ -79,9 +79,9 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
79 i++) { 79 i++) {
80 rx_ring = &qdev->rx_ring[i]; 80 rx_ring = &qdev->rx_ring[i];
81 cqicb = (struct cqicb *)rx_ring; 81 cqicb = (struct cqicb *)rx_ring;
82 cqicb->irq_delay = le16_to_cpu(qdev->rx_coalesce_usecs); 82 cqicb->irq_delay = cpu_to_le16(qdev->rx_coalesce_usecs);
83 cqicb->pkt_delay = 83 cqicb->pkt_delay =
84 le16_to_cpu(qdev->rx_max_coalesced_frames); 84 cpu_to_le16(qdev->rx_max_coalesced_frames);
85 cqicb->flags = FLAGS_LI; 85 cqicb->flags = FLAGS_LI;
86 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 86 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb),
87 CFG_LCQ, rx_ring->cq_id); 87 CFG_LCQ, rx_ring->cq_id);
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 718a7bd0cd1a..f4c016012f18 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -257,7 +257,7 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
257 { 257 {
258 status = 258 status =
259 ql_wait_reg_rdy(qdev, 259 ql_wait_reg_rdy(qdev,
260 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 260 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
261 if (status) 261 if (status)
262 goto exit; 262 goto exit;
263 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 263 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -265,13 +265,13 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
265 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */ 265 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */
266 status = 266 status =
267 ql_wait_reg_rdy(qdev, 267 ql_wait_reg_rdy(qdev,
268 MAC_ADDR_IDX, MAC_ADDR_MR, MAC_ADDR_E); 268 MAC_ADDR_IDX, MAC_ADDR_MR, 0);
269 if (status) 269 if (status)
270 goto exit; 270 goto exit;
271 *value++ = ql_read32(qdev, MAC_ADDR_DATA); 271 *value++ = ql_read32(qdev, MAC_ADDR_DATA);
272 status = 272 status =
273 ql_wait_reg_rdy(qdev, 273 ql_wait_reg_rdy(qdev,
274 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 274 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
275 if (status) 275 if (status)
276 goto exit; 276 goto exit;
277 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 277 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -279,14 +279,14 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
279 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */ 279 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */
280 status = 280 status =
281 ql_wait_reg_rdy(qdev, 281 ql_wait_reg_rdy(qdev,
282 MAC_ADDR_IDX, MAC_ADDR_MR, MAC_ADDR_E); 282 MAC_ADDR_IDX, MAC_ADDR_MR, 0);
283 if (status) 283 if (status)
284 goto exit; 284 goto exit;
285 *value++ = ql_read32(qdev, MAC_ADDR_DATA); 285 *value++ = ql_read32(qdev, MAC_ADDR_DATA);
286 if (type == MAC_ADDR_TYPE_CAM_MAC) { 286 if (type == MAC_ADDR_TYPE_CAM_MAC) {
287 status = 287 status =
288 ql_wait_reg_rdy(qdev, 288 ql_wait_reg_rdy(qdev,
289 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 289 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
290 if (status) 290 if (status)
291 goto exit; 291 goto exit;
292 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 292 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -294,7 +294,7 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
294 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */ 294 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */
295 status = 295 status =
296 ql_wait_reg_rdy(qdev, MAC_ADDR_IDX, 296 ql_wait_reg_rdy(qdev, MAC_ADDR_IDX,
297 MAC_ADDR_MR, MAC_ADDR_E); 297 MAC_ADDR_MR, 0);
298 if (status) 298 if (status)
299 goto exit; 299 goto exit;
300 *value++ = ql_read32(qdev, MAC_ADDR_DATA); 300 *value++ = ql_read32(qdev, MAC_ADDR_DATA);
@@ -344,7 +344,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
344 344
345 status = 345 status =
346 ql_wait_reg_rdy(qdev, 346 ql_wait_reg_rdy(qdev,
347 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 347 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
348 if (status) 348 if (status)
349 goto exit; 349 goto exit;
350 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 350 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -353,7 +353,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
353 ql_write32(qdev, MAC_ADDR_DATA, lower); 353 ql_write32(qdev, MAC_ADDR_DATA, lower);
354 status = 354 status =
355 ql_wait_reg_rdy(qdev, 355 ql_wait_reg_rdy(qdev,
356 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 356 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
357 if (status) 357 if (status)
358 goto exit; 358 goto exit;
359 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 359 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -362,7 +362,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
362 ql_write32(qdev, MAC_ADDR_DATA, upper); 362 ql_write32(qdev, MAC_ADDR_DATA, upper);
363 status = 363 status =
364 ql_wait_reg_rdy(qdev, 364 ql_wait_reg_rdy(qdev,
365 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 365 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
366 if (status) 366 if (status)
367 goto exit; 367 goto exit;
368 ql_write32(qdev, MAC_ADDR_IDX, (offset) | /* offset */ 368 ql_write32(qdev, MAC_ADDR_IDX, (offset) | /* offset */
@@ -400,7 +400,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
400 400
401 status = 401 status =
402 ql_wait_reg_rdy(qdev, 402 ql_wait_reg_rdy(qdev,
403 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 403 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
404 if (status) 404 if (status)
405 goto exit; 405 goto exit;
406 ql_write32(qdev, MAC_ADDR_IDX, offset | /* offset */ 406 ql_write32(qdev, MAC_ADDR_IDX, offset | /* offset */
@@ -431,13 +431,13 @@ int ql_get_routing_reg(struct ql_adapter *qdev, u32 index, u32 *value)
431 if (status) 431 if (status)
432 goto exit; 432 goto exit;
433 433
434 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MW, RT_IDX_E); 434 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MW, 0);
435 if (status) 435 if (status)
436 goto exit; 436 goto exit;
437 437
438 ql_write32(qdev, RT_IDX, 438 ql_write32(qdev, RT_IDX,
439 RT_IDX_TYPE_NICQ | RT_IDX_RS | (index << RT_IDX_IDX_SHIFT)); 439 RT_IDX_TYPE_NICQ | RT_IDX_RS | (index << RT_IDX_IDX_SHIFT));
440 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MR, RT_IDX_E); 440 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MR, 0);
441 if (status) 441 if (status)
442 goto exit; 442 goto exit;
443 *value = ql_read32(qdev, RT_DATA); 443 *value = ql_read32(qdev, RT_DATA);
@@ -874,7 +874,6 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
874{ 874{
875 int clean_idx = rx_ring->lbq_clean_idx; 875 int clean_idx = rx_ring->lbq_clean_idx;
876 struct bq_desc *lbq_desc; 876 struct bq_desc *lbq_desc;
877 struct bq_element *bq;
878 u64 map; 877 u64 map;
879 int i; 878 int i;
880 879
@@ -884,7 +883,6 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
884 "lbq: try cleaning clean_idx = %d.\n", 883 "lbq: try cleaning clean_idx = %d.\n",
885 clean_idx); 884 clean_idx);
886 lbq_desc = &rx_ring->lbq[clean_idx]; 885 lbq_desc = &rx_ring->lbq[clean_idx];
887 bq = lbq_desc->bq;
888 if (lbq_desc->p.lbq_page == NULL) { 886 if (lbq_desc->p.lbq_page == NULL) {
889 QPRINTK(qdev, RX_STATUS, DEBUG, 887 QPRINTK(qdev, RX_STATUS, DEBUG,
890 "lbq: getting new page for index %d.\n", 888 "lbq: getting new page for index %d.\n",
@@ -906,10 +904,7 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
906 } 904 }
907 pci_unmap_addr_set(lbq_desc, mapaddr, map); 905 pci_unmap_addr_set(lbq_desc, mapaddr, map);
908 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE); 906 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE);
909 bq->addr_lo = /*lbq_desc->addr_lo = */ 907 *lbq_desc->addr = cpu_to_le64(map);
910 cpu_to_le32(map);
911 bq->addr_hi = /*lbq_desc->addr_hi = */
912 cpu_to_le32(map >> 32);
913 } 908 }
914 clean_idx++; 909 clean_idx++;
915 if (clean_idx == rx_ring->lbq_len) 910 if (clean_idx == rx_ring->lbq_len)
@@ -934,7 +929,6 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
934{ 929{
935 int clean_idx = rx_ring->sbq_clean_idx; 930 int clean_idx = rx_ring->sbq_clean_idx;
936 struct bq_desc *sbq_desc; 931 struct bq_desc *sbq_desc;
937 struct bq_element *bq;
938 u64 map; 932 u64 map;
939 int i; 933 int i;
940 934
@@ -944,7 +938,6 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
944 QPRINTK(qdev, RX_STATUS, DEBUG, 938 QPRINTK(qdev, RX_STATUS, DEBUG,
945 "sbq: try cleaning clean_idx = %d.\n", 939 "sbq: try cleaning clean_idx = %d.\n",
946 clean_idx); 940 clean_idx);
947 bq = sbq_desc->bq;
948 if (sbq_desc->p.skb == NULL) { 941 if (sbq_desc->p.skb == NULL) {
949 QPRINTK(qdev, RX_STATUS, DEBUG, 942 QPRINTK(qdev, RX_STATUS, DEBUG,
950 "sbq: getting new skb for index %d.\n", 943 "sbq: getting new skb for index %d.\n",
@@ -963,11 +956,15 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
963 sbq_desc->p.skb->data, 956 sbq_desc->p.skb->data,
964 rx_ring->sbq_buf_size / 957 rx_ring->sbq_buf_size /
965 2, PCI_DMA_FROMDEVICE); 958 2, PCI_DMA_FROMDEVICE);
959 if (pci_dma_mapping_error(qdev->pdev, map)) {
960 QPRINTK(qdev, IFUP, ERR, "PCI mapping failed.\n");
961 rx_ring->sbq_clean_idx = clean_idx;
962 return;
963 }
966 pci_unmap_addr_set(sbq_desc, mapaddr, map); 964 pci_unmap_addr_set(sbq_desc, mapaddr, map);
967 pci_unmap_len_set(sbq_desc, maplen, 965 pci_unmap_len_set(sbq_desc, maplen,
968 rx_ring->sbq_buf_size / 2); 966 rx_ring->sbq_buf_size / 2);
969 bq->addr_lo = cpu_to_le32(map); 967 *sbq_desc->addr = cpu_to_le64(map);
970 bq->addr_hi = cpu_to_le32(map >> 32);
971 } 968 }
972 969
973 clean_idx++; 970 clean_idx++;
@@ -1303,6 +1300,11 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
1303 "No skb available, drop the packet.\n"); 1300 "No skb available, drop the packet.\n");
1304 return NULL; 1301 return NULL;
1305 } 1302 }
1303 pci_unmap_page(qdev->pdev,
1304 pci_unmap_addr(lbq_desc,
1305 mapaddr),
1306 pci_unmap_len(lbq_desc, maplen),
1307 PCI_DMA_FROMDEVICE);
1306 skb_reserve(skb, NET_IP_ALIGN); 1308 skb_reserve(skb, NET_IP_ALIGN);
1307 QPRINTK(qdev, RX_STATUS, DEBUG, 1309 QPRINTK(qdev, RX_STATUS, DEBUG,
1308 "%d bytes of headers and data in large. Chain page to new skb and pull tail.\n", length); 1310 "%d bytes of headers and data in large. Chain page to new skb and pull tail.\n", length);
@@ -1330,7 +1332,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
1330 * eventually be in trouble. 1332 * eventually be in trouble.
1331 */ 1333 */
1332 int size, offset, i = 0; 1334 int size, offset, i = 0;
1333 struct bq_element *bq, bq_array[8]; 1335 __le64 *bq, bq_array[8];
1334 sbq_desc = ql_get_curr_sbuf(rx_ring); 1336 sbq_desc = ql_get_curr_sbuf(rx_ring);
1335 pci_unmap_single(qdev->pdev, 1337 pci_unmap_single(qdev->pdev,
1336 pci_unmap_addr(sbq_desc, mapaddr), 1338 pci_unmap_addr(sbq_desc, mapaddr),
@@ -1356,16 +1358,10 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
1356 } else { 1358 } else {
1357 QPRINTK(qdev, RX_STATUS, DEBUG, 1359 QPRINTK(qdev, RX_STATUS, DEBUG,
1358 "Headers in small, %d bytes of data in chain of large.\n", length); 1360 "Headers in small, %d bytes of data in chain of large.\n", length);
1359 bq = (struct bq_element *)sbq_desc->p.skb->data; 1361 bq = (__le64 *)sbq_desc->p.skb->data;
1360 } 1362 }
1361 while (length > 0) { 1363 while (length > 0) {
1362 lbq_desc = ql_get_curr_lbuf(rx_ring); 1364 lbq_desc = ql_get_curr_lbuf(rx_ring);
1363 if ((bq->addr_lo & ~BQ_MASK) != lbq_desc->bq->addr_lo) {
1364 QPRINTK(qdev, RX_STATUS, ERR,
1365 "Panic!!! bad large buffer address, expected 0x%.08x, got 0x%.08x.\n",
1366 lbq_desc->bq->addr_lo, bq->addr_lo);
1367 return NULL;
1368 }
1369 pci_unmap_page(qdev->pdev, 1365 pci_unmap_page(qdev->pdev,
1370 pci_unmap_addr(lbq_desc, 1366 pci_unmap_addr(lbq_desc,
1371 mapaddr), 1367 mapaddr),
@@ -1549,7 +1545,7 @@ static void ql_process_chip_ae_intr(struct ql_adapter *qdev,
1549static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) 1545static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1550{ 1546{
1551 struct ql_adapter *qdev = rx_ring->qdev; 1547 struct ql_adapter *qdev = rx_ring->qdev;
1552 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1548 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1553 struct ob_mac_iocb_rsp *net_rsp = NULL; 1549 struct ob_mac_iocb_rsp *net_rsp = NULL;
1554 int count = 0; 1550 int count = 0;
1555 1551
@@ -1575,7 +1571,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1575 } 1571 }
1576 count++; 1572 count++;
1577 ql_update_cq(rx_ring); 1573 ql_update_cq(rx_ring);
1578 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1574 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1579 } 1575 }
1580 ql_write_cq_idx(rx_ring); 1576 ql_write_cq_idx(rx_ring);
1581 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) { 1577 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) {
@@ -1595,7 +1591,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1595static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) 1591static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1596{ 1592{
1597 struct ql_adapter *qdev = rx_ring->qdev; 1593 struct ql_adapter *qdev = rx_ring->qdev;
1598 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1594 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1599 struct ql_net_rsp_iocb *net_rsp; 1595 struct ql_net_rsp_iocb *net_rsp;
1600 int count = 0; 1596 int count = 0;
1601 1597
@@ -1628,7 +1624,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1628 } 1624 }
1629 count++; 1625 count++;
1630 ql_update_cq(rx_ring); 1626 ql_update_cq(rx_ring);
1631 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1627 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1632 if (count == budget) 1628 if (count == budget)
1633 break; 1629 break;
1634 } 1630 }
@@ -1791,7 +1787,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1791 * Check the default queue and wake handler if active. 1787 * Check the default queue and wake handler if active.
1792 */ 1788 */
1793 rx_ring = &qdev->rx_ring[0]; 1789 rx_ring = &qdev->rx_ring[0];
1794 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) { 1790 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) {
1795 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n"); 1791 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n");
1796 ql_disable_completion_interrupt(qdev, intr_context->intr); 1792 ql_disable_completion_interrupt(qdev, intr_context->intr);
1797 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue, 1793 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue,
@@ -1805,7 +1801,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1805 */ 1801 */
1806 for (i = 1; i < qdev->rx_ring_count; i++) { 1802 for (i = 1; i < qdev->rx_ring_count; i++) {
1807 rx_ring = &qdev->rx_ring[i]; 1803 rx_ring = &qdev->rx_ring[i];
1808 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) != 1804 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) !=
1809 rx_ring->cnsmr_idx) { 1805 rx_ring->cnsmr_idx) {
1810 QPRINTK(qdev, INTR, INFO, 1806 QPRINTK(qdev, INTR, INFO,
1811 "Waking handler for rx_ring[%d].\n", i); 1807 "Waking handler for rx_ring[%d].\n", i);
@@ -1874,7 +1870,7 @@ static void ql_hw_csum_setup(struct sk_buff *skb,
1874{ 1870{
1875 int len; 1871 int len;
1876 struct iphdr *iph = ip_hdr(skb); 1872 struct iphdr *iph = ip_hdr(skb);
1877 u16 *check; 1873 __sum16 *check;
1878 mac_iocb_ptr->opcode = OPCODE_OB_MAC_TSO_IOCB; 1874 mac_iocb_ptr->opcode = OPCODE_OB_MAC_TSO_IOCB;
1879 mac_iocb_ptr->frame_len = cpu_to_le32((u32) skb->len); 1875 mac_iocb_ptr->frame_len = cpu_to_le32((u32) skb->len);
1880 mac_iocb_ptr->net_trans_offset = 1876 mac_iocb_ptr->net_trans_offset =
@@ -2083,8 +2079,6 @@ static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring
2083 put_page(lbq_desc->p.lbq_page); 2079 put_page(lbq_desc->p.lbq_page);
2084 lbq_desc->p.lbq_page = NULL; 2080 lbq_desc->p.lbq_page = NULL;
2085 } 2081 }
2086 lbq_desc->bq->addr_lo = 0;
2087 lbq_desc->bq->addr_hi = 0;
2088 } 2082 }
2089} 2083}
2090 2084
@@ -2097,12 +2091,12 @@ static int ql_alloc_lbq_buffers(struct ql_adapter *qdev,
2097 int i; 2091 int i;
2098 struct bq_desc *lbq_desc; 2092 struct bq_desc *lbq_desc;
2099 u64 map; 2093 u64 map;
2100 struct bq_element *bq = rx_ring->lbq_base; 2094 __le64 *bq = rx_ring->lbq_base;
2101 2095
2102 for (i = 0; i < rx_ring->lbq_len; i++) { 2096 for (i = 0; i < rx_ring->lbq_len; i++) {
2103 lbq_desc = &rx_ring->lbq[i]; 2097 lbq_desc = &rx_ring->lbq[i];
2104 memset(lbq_desc, 0, sizeof(lbq_desc)); 2098 memset(lbq_desc, 0, sizeof(lbq_desc));
2105 lbq_desc->bq = bq; 2099 lbq_desc->addr = bq;
2106 lbq_desc->index = i; 2100 lbq_desc->index = i;
2107 lbq_desc->p.lbq_page = alloc_page(GFP_ATOMIC); 2101 lbq_desc->p.lbq_page = alloc_page(GFP_ATOMIC);
2108 if (unlikely(!lbq_desc->p.lbq_page)) { 2102 if (unlikely(!lbq_desc->p.lbq_page)) {
@@ -2119,8 +2113,7 @@ static int ql_alloc_lbq_buffers(struct ql_adapter *qdev,
2119 } 2113 }
2120 pci_unmap_addr_set(lbq_desc, mapaddr, map); 2114 pci_unmap_addr_set(lbq_desc, mapaddr, map);
2121 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE); 2115 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE);
2122 bq->addr_lo = cpu_to_le32(map); 2116 *lbq_desc->addr = cpu_to_le64(map);
2123 bq->addr_hi = cpu_to_le32(map >> 32);
2124 } 2117 }
2125 bq++; 2118 bq++;
2126 } 2119 }
@@ -2149,13 +2142,6 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring
2149 dev_kfree_skb(sbq_desc->p.skb); 2142 dev_kfree_skb(sbq_desc->p.skb);
2150 sbq_desc->p.skb = NULL; 2143 sbq_desc->p.skb = NULL;
2151 } 2144 }
2152 if (sbq_desc->bq == NULL) {
2153 QPRINTK(qdev, IFUP, ERR, "sbq_desc->bq %d is NULL.\n",
2154 i);
2155 return;
2156 }
2157 sbq_desc->bq->addr_lo = 0;
2158 sbq_desc->bq->addr_hi = 0;
2159 } 2145 }
2160} 2146}
2161 2147
@@ -2167,13 +2153,13 @@ static int ql_alloc_sbq_buffers(struct ql_adapter *qdev,
2167 struct bq_desc *sbq_desc; 2153 struct bq_desc *sbq_desc;
2168 struct sk_buff *skb; 2154 struct sk_buff *skb;
2169 u64 map; 2155 u64 map;
2170 struct bq_element *bq = rx_ring->sbq_base; 2156 __le64 *bq = rx_ring->sbq_base;
2171 2157
2172 for (i = 0; i < rx_ring->sbq_len; i++) { 2158 for (i = 0; i < rx_ring->sbq_len; i++) {
2173 sbq_desc = &rx_ring->sbq[i]; 2159 sbq_desc = &rx_ring->sbq[i];
2174 memset(sbq_desc, 0, sizeof(sbq_desc)); 2160 memset(sbq_desc, 0, sizeof(sbq_desc));
2175 sbq_desc->index = i; 2161 sbq_desc->index = i;
2176 sbq_desc->bq = bq; 2162 sbq_desc->addr = bq;
2177 skb = netdev_alloc_skb(qdev->ndev, rx_ring->sbq_buf_size); 2163 skb = netdev_alloc_skb(qdev->ndev, rx_ring->sbq_buf_size);
2178 if (unlikely(!skb)) { 2164 if (unlikely(!skb)) {
2179 /* Better luck next round */ 2165 /* Better luck next round */
@@ -2199,10 +2185,7 @@ static int ql_alloc_sbq_buffers(struct ql_adapter *qdev,
2199 } 2185 }
2200 pci_unmap_addr_set(sbq_desc, mapaddr, map); 2186 pci_unmap_addr_set(sbq_desc, mapaddr, map);
2201 pci_unmap_len_set(sbq_desc, maplen, rx_ring->sbq_buf_size / 2); 2187 pci_unmap_len_set(sbq_desc, maplen, rx_ring->sbq_buf_size / 2);
2202 bq->addr_lo = /*sbq_desc->addr_lo = */ 2188 *sbq_desc->addr = cpu_to_le64(map);
2203 cpu_to_le32(map);
2204 bq->addr_hi = /*sbq_desc->addr_hi = */
2205 cpu_to_le32(map >> 32);
2206 bq++; 2189 bq++;
2207 } 2190 }
2208 return 0; 2191 return 0;
@@ -2481,7 +2464,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2481 memset((void *)cqicb, 0, sizeof(struct cqicb)); 2464 memset((void *)cqicb, 0, sizeof(struct cqicb));
2482 cqicb->msix_vect = rx_ring->irq; 2465 cqicb->msix_vect = rx_ring->irq;
2483 2466
2484 cqicb->len = cpu_to_le16(rx_ring->cq_len | LEN_V | LEN_CPP_CONT); 2467 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len;
2468 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT);
2485 2469
2486 cqicb->addr_lo = cpu_to_le32(rx_ring->cq_base_dma); 2470 cqicb->addr_lo = cpu_to_le32(rx_ring->cq_base_dma);
2487 cqicb->addr_hi = cpu_to_le32((u64) rx_ring->cq_base_dma >> 32); 2471 cqicb->addr_hi = cpu_to_le32((u64) rx_ring->cq_base_dma >> 32);
@@ -2503,8 +2487,11 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2503 cpu_to_le32(rx_ring->lbq_base_indirect_dma); 2487 cpu_to_le32(rx_ring->lbq_base_indirect_dma);
2504 cqicb->lbq_addr_hi = 2488 cqicb->lbq_addr_hi =
2505 cpu_to_le32((u64) rx_ring->lbq_base_indirect_dma >> 32); 2489 cpu_to_le32((u64) rx_ring->lbq_base_indirect_dma >> 32);
2506 cqicb->lbq_buf_size = cpu_to_le32(rx_ring->lbq_buf_size); 2490 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 :
2507 bq_len = (u16) rx_ring->lbq_len; 2491 (u16) rx_ring->lbq_buf_size;
2492 cqicb->lbq_buf_size = cpu_to_le16(bq_len);
2493 bq_len = (rx_ring->lbq_len == 65536) ? 0 :
2494 (u16) rx_ring->lbq_len;
2508 cqicb->lbq_len = cpu_to_le16(bq_len); 2495 cqicb->lbq_len = cpu_to_le16(bq_len);
2509 rx_ring->lbq_prod_idx = rx_ring->lbq_len - 16; 2496 rx_ring->lbq_prod_idx = rx_ring->lbq_len - 16;
2510 rx_ring->lbq_curr_idx = 0; 2497 rx_ring->lbq_curr_idx = 0;
@@ -2520,7 +2507,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2520 cpu_to_le32((u64) rx_ring->sbq_base_indirect_dma >> 32); 2507 cpu_to_le32((u64) rx_ring->sbq_base_indirect_dma >> 32);
2521 cqicb->sbq_buf_size = 2508 cqicb->sbq_buf_size =
2522 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8); 2509 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8);
2523 bq_len = (u16) rx_ring->sbq_len; 2510 bq_len = (rx_ring->sbq_len == 65536) ? 0 :
2511 (u16) rx_ring->sbq_len;
2524 cqicb->sbq_len = cpu_to_le16(bq_len); 2512 cqicb->sbq_len = cpu_to_le16(bq_len);
2525 rx_ring->sbq_prod_idx = rx_ring->sbq_len - 16; 2513 rx_ring->sbq_prod_idx = rx_ring->sbq_len - 16;
2526 rx_ring->sbq_curr_idx = 0; 2514 rx_ring->sbq_curr_idx = 0;
@@ -3341,11 +3329,11 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3341 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); 3329 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb);
3342 rx_ring->lbq_len = NUM_LARGE_BUFFERS; 3330 rx_ring->lbq_len = NUM_LARGE_BUFFERS;
3343 rx_ring->lbq_size = 3331 rx_ring->lbq_size =
3344 rx_ring->lbq_len * sizeof(struct bq_element); 3332 rx_ring->lbq_len * sizeof(__le64);
3345 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE; 3333 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE;
3346 rx_ring->sbq_len = NUM_SMALL_BUFFERS; 3334 rx_ring->sbq_len = NUM_SMALL_BUFFERS;
3347 rx_ring->sbq_size = 3335 rx_ring->sbq_size =
3348 rx_ring->sbq_len * sizeof(struct bq_element); 3336 rx_ring->sbq_len * sizeof(__le64);
3349 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2; 3337 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2;
3350 rx_ring->type = DEFAULT_Q; 3338 rx_ring->type = DEFAULT_Q;
3351 } else if (i < qdev->rss_ring_first_cq_id) { 3339 } else if (i < qdev->rss_ring_first_cq_id) {
@@ -3372,11 +3360,11 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3372 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); 3360 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb);
3373 rx_ring->lbq_len = NUM_LARGE_BUFFERS; 3361 rx_ring->lbq_len = NUM_LARGE_BUFFERS;
3374 rx_ring->lbq_size = 3362 rx_ring->lbq_size =
3375 rx_ring->lbq_len * sizeof(struct bq_element); 3363 rx_ring->lbq_len * sizeof(__le64);
3376 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE; 3364 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE;
3377 rx_ring->sbq_len = NUM_SMALL_BUFFERS; 3365 rx_ring->sbq_len = NUM_SMALL_BUFFERS;
3378 rx_ring->sbq_size = 3366 rx_ring->sbq_size =
3379 rx_ring->sbq_len * sizeof(struct bq_element); 3367 rx_ring->sbq_len * sizeof(__le64);
3380 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2; 3368 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2;
3381 rx_ring->type = RX_Q; 3369 rx_ring->type = RX_Q;
3382 } 3370 }
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index f54ac2389da2..57fb1f71c47b 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -42,11 +42,11 @@
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include <linux/if_vlan.h> 43#include <linux/if_vlan.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/firmware.h>
45#include <asm/processor.h> /* Processor type for cache alignment. */ 46#include <asm/processor.h> /* Processor type for cache alignment. */
46#include <asm/uaccess.h> 47#include <asm/uaccess.h>
47#include <asm/io.h> 48#include <asm/io.h>
48 49
49#include "starfire_firmware.h"
50/* 50/*
51 * The current frame processor firmware fails to checksum a fragment 51 * The current frame processor firmware fails to checksum a fragment
52 * of length 1. If and when this is fixed, the #define below can be removed. 52 * of length 1. If and when this is fixed, the #define below can be removed.
@@ -173,6 +173,10 @@ static int full_duplex[MAX_UNITS] = {0, };
173#define skb_first_frag_len(skb) skb_headlen(skb) 173#define skb_first_frag_len(skb) skb_headlen(skb)
174#define skb_num_frags(skb) (skb_shinfo(skb)->nr_frags + 1) 174#define skb_num_frags(skb) (skb_shinfo(skb)->nr_frags + 1)
175 175
176/* Firmware names */
177#define FIRMWARE_RX "adaptec/starfire_rx.bin"
178#define FIRMWARE_TX "adaptec/starfire_tx.bin"
179
176/* These identify the driver base version and may not be removed. */ 180/* These identify the driver base version and may not be removed. */
177static char version[] = 181static char version[] =
178KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n" 182KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n"
@@ -182,6 +186,8 @@ MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
182MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver"); 186MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver");
183MODULE_LICENSE("GPL"); 187MODULE_LICENSE("GPL");
184MODULE_VERSION(DRV_VERSION); 188MODULE_VERSION(DRV_VERSION);
189MODULE_FIRMWARE(FIRMWARE_RX);
190MODULE_FIRMWARE(FIRMWARE_TX);
185 191
186module_param(max_interrupt_work, int, 0); 192module_param(max_interrupt_work, int, 0);
187module_param(mtu, int, 0); 193module_param(mtu, int, 0);
@@ -902,9 +908,12 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
902 908
903static int netdev_open(struct net_device *dev) 909static int netdev_open(struct net_device *dev)
904{ 910{
911 const struct firmware *fw_rx, *fw_tx;
912 const __be32 *fw_rx_data, *fw_tx_data;
905 struct netdev_private *np = netdev_priv(dev); 913 struct netdev_private *np = netdev_priv(dev);
906 void __iomem *ioaddr = np->base; 914 void __iomem *ioaddr = np->base;
907 int i, retval; 915 int i, retval;
916 size_t tx_size, rx_size;
908 size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size; 917 size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size;
909 918
910 /* Do we ever need to reset the chip??? */ 919 /* Do we ever need to reset the chip??? */
@@ -1040,11 +1049,40 @@ static int netdev_open(struct net_device *dev)
1040 writel(ETH_P_8021Q, ioaddr + VlanType); 1049 writel(ETH_P_8021Q, ioaddr + VlanType);
1041#endif /* VLAN_SUPPORT */ 1050#endif /* VLAN_SUPPORT */
1042 1051
1052 retval = request_firmware(&fw_rx, FIRMWARE_RX, &np->pci_dev->dev);
1053 if (retval) {
1054 printk(KERN_ERR "starfire: Failed to load firmware \"%s\"\n",
1055 FIRMWARE_RX);
1056 return retval;
1057 }
1058 if (fw_rx->size % 4) {
1059 printk(KERN_ERR "starfire: bogus length %zu in \"%s\"\n",
1060 fw_rx->size, FIRMWARE_RX);
1061 retval = -EINVAL;
1062 goto out_rx;
1063 }
1064 retval = request_firmware(&fw_tx, FIRMWARE_TX, &np->pci_dev->dev);
1065 if (retval) {
1066 printk(KERN_ERR "starfire: Failed to load firmware \"%s\"\n",
1067 FIRMWARE_TX);
1068 goto out_rx;
1069 }
1070 if (fw_tx->size % 4) {
1071 printk(KERN_ERR "starfire: bogus length %zu in \"%s\"\n",
1072 fw_tx->size, FIRMWARE_TX);
1073 retval = -EINVAL;
1074 goto out_tx;
1075 }
1076 fw_rx_data = (const __be32 *)&fw_rx->data[0];
1077 fw_tx_data = (const __be32 *)&fw_tx->data[0];
1078 rx_size = fw_rx->size / 4;
1079 tx_size = fw_tx->size / 4;
1080
1043 /* Load Rx/Tx firmware into the frame processors */ 1081 /* Load Rx/Tx firmware into the frame processors */
1044 for (i = 0; i < FIRMWARE_RX_SIZE * 2; i++) 1082 for (i = 0; i < rx_size; i++)
1045 writel(firmware_rx[i], ioaddr + RxGfpMem + i * 4); 1083 writel(be32_to_cpup(&fw_rx_data[i]), ioaddr + RxGfpMem + i * 4);
1046 for (i = 0; i < FIRMWARE_TX_SIZE * 2; i++) 1084 for (i = 0; i < tx_size; i++)
1047 writel(firmware_tx[i], ioaddr + TxGfpMem + i * 4); 1085 writel(be32_to_cpup(&fw_tx_data[i]), ioaddr + TxGfpMem + i * 4);
1048 if (enable_hw_cksum) 1086 if (enable_hw_cksum)
1049 /* Enable the Rx and Tx units, and the Rx/Tx frame processors. */ 1087 /* Enable the Rx and Tx units, and the Rx/Tx frame processors. */
1050 writel(TxEnable|TxGFPEnable|RxEnable|RxGFPEnable, ioaddr + GenCtrl); 1088 writel(TxEnable|TxGFPEnable|RxEnable|RxGFPEnable, ioaddr + GenCtrl);
@@ -1056,7 +1094,11 @@ static int netdev_open(struct net_device *dev)
1056 printk(KERN_DEBUG "%s: Done netdev_open().\n", 1094 printk(KERN_DEBUG "%s: Done netdev_open().\n",
1057 dev->name); 1095 dev->name);
1058 1096
1059 return 0; 1097out_tx:
1098 release_firmware(fw_tx);
1099out_rx:
1100 release_firmware(fw_rx);
1101 return retval;
1060} 1102}
1061 1103
1062 1104
diff --git a/drivers/net/starfire_firmware.h b/drivers/net/starfire_firmware.h
deleted file mode 100644
index 0a668528955d..000000000000
--- a/drivers/net/starfire_firmware.h
+++ /dev/null
@@ -1,346 +0,0 @@
1/*
2 * Copyright 2003 Adaptec, Inc.
3 *
4 * Please read the following license before using the Adaptec Software
5 * ("Program"). If you do not agree to the license terms, do not use the
6 * Program:
7 *
8 * You agree to be bound by version 2 of the General Public License ("GPL")
9 * dated June 1991, which can be found at http://www.fsf.org/licenses/gpl.html.
10 * If the link is broken, write to Free Software Foundation, 59 Temple Place,
11 * Boston, Massachusetts 02111-1307.
12 *
13 * BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE IT IS LICENSED "AS IS" AND
14 * THERE IS NO WARRANTY FOR THE PROGRAM, INCLUDING BUT NOT LIMITED TO THE
15 * IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * (TO THE EXTENT PERMITTED BY APPLICABLE LAW). USE OF THE PROGRAM IS AT YOUR
17 * OWN RISK. IN NO EVENT WILL ADAPTEC OR ITS LICENSORS BE LIABLE TO YOU FOR
18 * DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
19 * ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM.
20 *
21 */
22
23static const u32 firmware_rx[] = {
24 0x010003dc, 0x00000000,
25 0x04000421, 0x00000086,
26 0x80000015, 0x0000180e,
27 0x81000015, 0x00006664,
28 0x1a0040ab, 0x00000b06,
29 0x14200011, 0x00000000,
30 0x14204022, 0x0000aaaa,
31 0x14204022, 0x00000300,
32 0x14204022, 0x00000000,
33 0x1a0040ab, 0x00000b14,
34 0x14200011, 0x00000000,
35 0x83000015, 0x00000002,
36 0x04000021, 0x00000000,
37 0x00000010, 0x00000000,
38 0x04000421, 0x00000087,
39 0x00000010, 0x00000000,
40 0x00000010, 0x00000000,
41 0x00008015, 0x00000000,
42 0x0000003e, 0x00000000,
43 0x00000010, 0x00000000,
44 0x82000015, 0x00004000,
45 0x009e8050, 0x00000000,
46 0x03008015, 0x00000000,
47 0x86008015, 0x00000000,
48 0x82000015, 0x00008000,
49 0x0100001c, 0x00000000,
50 0x000050a0, 0x0000010c,
51 0x4e20d011, 0x00006008,
52 0x1420d012, 0x00004008,
53 0x0000f090, 0x00007000,
54 0x0000c8b0, 0x00003000,
55 0x00004040, 0x00000000,
56 0x00108015, 0x00000000,
57 0x00a2c150, 0x00004000,
58 0x00a400b0, 0x00000014,
59 0x00000020, 0x00000000,
60 0x2500400d, 0x00002525,
61 0x00047220, 0x00003100,
62 0x00934070, 0x00000000,
63 0x00000020, 0x00000000,
64 0x00924460, 0x00000184,
65 0x2b20c011, 0x00000000,
66 0x0000c420, 0x00000540,
67 0x36014018, 0x0000422d,
68 0x14200011, 0x00000000,
69 0x00924460, 0x00000183,
70 0x3200001f, 0x00000034,
71 0x02ac0015, 0x00000002,
72 0x00a60110, 0x00000008,
73 0x42200011, 0x00000000,
74 0x00924060, 0x00000103,
75 0x0000001e, 0x00000000,
76 0x00000020, 0x00000100,
77 0x0000001e, 0x00000000,
78 0x00924460, 0x00000086,
79 0x00004080, 0x00000000,
80 0x0092c070, 0x00000000,
81 0x00924060, 0x00000100,
82 0x0000c890, 0x00005000,
83 0x00a6c110, 0x00000000,
84 0x00b0c090, 0x00000012,
85 0x021c0015, 0x00000000,
86 0x3200001f, 0x00000034,
87 0x00924460, 0x00000510,
88 0x44210011, 0x00000000,
89 0x42000011, 0x00000000,
90 0x83000015, 0x00000040,
91 0x00924460, 0x00000508,
92 0x45014018, 0x00004545,
93 0x00808050, 0x00000000,
94 0x62208012, 0x00000000,
95 0x82000015, 0x00000800,
96 0x15200011, 0x00000000,
97 0x00000010, 0x00000000,
98 0x00000010, 0x00000000,
99 0x00000010, 0x00000000,
100 0x00000010, 0x00000000,
101 0x00000010, 0x00000000,
102 0x80000015, 0x0000eea4,
103 0x81000015, 0x0000005f,
104 0x00000060, 0x00000000,
105 0x00004120, 0x00000000,
106 0x00004a00, 0x00004000,
107 0x00924460, 0x00000190,
108 0x5601401a, 0x00005956,
109 0x14000011, 0x00000000,
110 0x00934050, 0x00000018,
111 0x00930050, 0x00000018,
112 0x3601403a, 0x0000002d,
113 0x000643a9, 0x00000000,
114 0x0000c420, 0x00000140,
115 0x5601401a, 0x00005956,
116 0x14000011, 0x00000000,
117 0x00000010, 0x00000000,
118 0x00000010, 0x00000000,
119 0x000642a9, 0x00000000,
120 0x00024420, 0x00000183,
121 0x5601401a, 0x00005956,
122 0x82000015, 0x00002000,
123 0x15200011, 0x00000000,
124 0x82000015, 0x00000010,
125 0x15200011, 0x00000000,
126 0x82000015, 0x00000010,
127 0x15200011, 0x00000000,
128}; /* 104 Rx instructions */
129#define FIRMWARE_RX_SIZE 104
130
131static const u32 firmware_tx[] = {
132 0x010003dc, 0x00000000,
133 0x04000421, 0x00000086,
134 0x80000015, 0x0000180e,
135 0x81000015, 0x00006664,
136 0x1a0040ab, 0x00000b06,
137 0x14200011, 0x00000000,
138 0x14204022, 0x0000aaaa,
139 0x14204022, 0x00000300,
140 0x14204022, 0x00000000,
141 0x1a0040ab, 0x00000b14,
142 0x14200011, 0x00000000,
143 0x83000015, 0x00000002,
144 0x04000021, 0x00000000,
145 0x00000010, 0x00000000,
146 0x04000421, 0x00000087,
147 0x00000010, 0x00000000,
148 0x00000010, 0x00000000,
149 0x00008015, 0x00000000,
150 0x0000003e, 0x00000000,
151 0x00000010, 0x00000000,
152 0x82000015, 0x00004000,
153 0x009e8050, 0x00000000,
154 0x03008015, 0x00000000,
155 0x86008015, 0x00000000,
156 0x82000015, 0x00008000,
157 0x0100001c, 0x00000000,
158 0x000050a0, 0x0000010c,
159 0x4e20d011, 0x00006008,
160 0x1420d012, 0x00004008,
161 0x0000f090, 0x00007000,
162 0x0000c8b0, 0x00003000,
163 0x00004040, 0x00000000,
164 0x00108015, 0x00000000,
165 0x00a2c150, 0x00004000,
166 0x00a400b0, 0x00000014,
167 0x00000020, 0x00000000,
168 0x2500400d, 0x00002525,
169 0x00047220, 0x00003100,
170 0x00934070, 0x00000000,
171 0x00000020, 0x00000000,
172 0x00924460, 0x00000184,
173 0x2b20c011, 0x00000000,
174 0x0000c420, 0x00000540,
175 0x36014018, 0x0000422d,
176 0x14200011, 0x00000000,
177 0x00924460, 0x00000183,
178 0x3200001f, 0x00000034,
179 0x02ac0015, 0x00000002,
180 0x00a60110, 0x00000008,
181 0x42200011, 0x00000000,
182 0x00924060, 0x00000103,
183 0x0000001e, 0x00000000,
184 0x00000020, 0x00000100,
185 0x0000001e, 0x00000000,
186 0x00924460, 0x00000086,
187 0x00004080, 0x00000000,
188 0x0092c070, 0x00000000,
189 0x00924060, 0x00000100,
190 0x0000c890, 0x00005000,
191 0x00a6c110, 0x00000000,
192 0x00b0c090, 0x00000012,
193 0x021c0015, 0x00000000,
194 0x3200001f, 0x00000034,
195 0x00924460, 0x00000510,
196 0x44210011, 0x00000000,
197 0x42000011, 0x00000000,
198 0x83000015, 0x00000040,
199 0x00924460, 0x00000508,
200 0x45014018, 0x00004545,
201 0x00808050, 0x00000000,
202 0x62208012, 0x00000000,
203 0x82000015, 0x00000800,
204 0x15200011, 0x00000000,
205 0x00000010, 0x00000000,
206 0x00000010, 0x00000000,
207 0x00000010, 0x00000000,
208 0x00000010, 0x00000000,
209 0x00000010, 0x00000000,
210 0x80000015, 0x0000eea4,
211 0x81000015, 0x0000005f,
212 0x00000060, 0x00000000,
213 0x00004120, 0x00000000,
214 0x00004a00, 0x00004000,
215 0x00924460, 0x00000190,
216 0x5601401a, 0x00005956,
217 0x14000011, 0x00000000,
218 0x00934050, 0x00000018,
219 0x00930050, 0x00000018,
220 0x3601403a, 0x0000002d,
221 0x000643a9, 0x00000000,
222 0x0000c420, 0x00000140,
223 0x5601401a, 0x00005956,
224 0x14000011, 0x00000000,
225 0x00000010, 0x00000000,
226 0x00000010, 0x00000000,
227 0x000642a9, 0x00000000,
228 0x00024420, 0x00000183,
229 0x5601401a, 0x00005956,
230 0x82000015, 0x00002000,
231 0x15200011, 0x00000000,
232 0x82000015, 0x00000010,
233 0x15200011, 0x00000000,
234 0x82000015, 0x00000010,
235 0x15200011, 0x00000000,
236}; /* 104 Tx instructions */
237#define FIRMWARE_TX_SIZE 104
238#if 0
239static const u32 firmware_wol[] = {
240 0x010003dc, 0x00000000,
241 0x19000421, 0x00000087,
242 0x80000015, 0x00001a1a,
243 0x81000015, 0x00001a1a,
244 0x1a0040ab, 0x00000b06,
245 0x15200011, 0x00000000,
246 0x15204022, 0x0000aaaa,
247 0x15204022, 0x00000300,
248 0x15204022, 0x00000000,
249 0x1a0040ab, 0x00000b15,
250 0x15200011, 0x00000000,
251 0x83000015, 0x00000002,
252 0x04000021, 0x00000000,
253 0x00000010, 0x00000000,
254 0x04000421, 0x00000087,
255 0x00000010, 0x00000000,
256 0x00000010, 0x00000000,
257 0x00008015, 0x00000000,
258 0x0000003e, 0x00000000,
259 0x00000010, 0x00000000,
260 0x00000010, 0x00000000,
261 0x82000015, 0x00004000,
262 0x82000015, 0x00008000,
263 0x0000000c, 0x00000000,
264 0x00000010, 0x00000000,
265 0x00004080, 0x00000100,
266 0x1f20c011, 0x00001122,
267 0x2720f011, 0x00003011,
268 0x19200071, 0x00000000,
269 0x1a200051, 0x00000000,
270 0x00000010, 0x00000000,
271 0x00000010, 0x00000000,
272 0x1d2040a4, 0x00003344,
273 0x1d2040a2, 0x00005566,
274 0x000040a0, 0x00000100,
275 0x00108050, 0x00000001,
276 0x1a208012, 0x00000006,
277 0x82000015, 0x00008080,
278 0x010003dc, 0x00000000,
279 0x1d2040a4, 0x00002233,
280 0x1d2040a4, 0x00004455,
281 0x2d208011, 0x00000005,
282 0x1d2040a4, 0x00006611,
283 0x00108050, 0x00000001,
284 0x27200011, 0x00000000,
285 0x1d2050a4, 0x00006600,
286 0x82000015, 0x00008080,
287 0x010003dc, 0x00000000,
288 0x00000050, 0x00000000,
289 0x1b200031, 0x00000000,
290 0x0000001e, 0x00000000,
291 0x0000001e, 0x00000000,
292 0x0000001e, 0x00000000,
293 0x0000001e, 0x00000000,
294 0x00924460, 0x00000086,
295 0x00004080, 0x00000000,
296 0x0092c070, 0x00000000,
297 0x00924060, 0x00000100,
298 0x0000c890, 0x00005000,
299 0x00a6c110, 0x00000000,
300 0x00b0c090, 0x00000012,
301 0x021c0015, 0x00000000,
302 0x3200001f, 0x00000034,
303 0x00924460, 0x00000510,
304 0x44210011, 0x00000000,
305 0x42000011, 0x00000000,
306 0x83000015, 0x00000040,
307 0x00924460, 0x00000508,
308 0x476a0012, 0x00000100,
309 0x83000015, 0x00000008,
310 0x16200011, 0x00000000,
311 0x001e8050, 0x00000000,
312 0x001e8050, 0x00000000,
313 0x00808050, 0x00000000,
314 0x03008015, 0x00000000,
315 0x62208012, 0x00000000,
316 0x82000015, 0x00000800,
317 0x16200011, 0x00000000,
318 0x80000015, 0x0000eea4,
319 0x81000015, 0x0000005f,
320 0x00000020, 0x00000000,
321 0x00004120, 0x00000000,
322 0x00004a00, 0x00004000,
323 0x00924460, 0x00000190,
324 0x5c01401a, 0x0000595c,
325 0x15000011, 0x00000000,
326 0x00934050, 0x00000018,
327 0x00930050, 0x00000018,
328 0x3601403a, 0x0000002d,
329 0x00064029, 0x00000000,
330 0x0000c420, 0x00000140,
331 0x5c01401a, 0x0000595c,
332 0x15000011, 0x00000000,
333 0x00000010, 0x00000000,
334 0x00000010, 0x00000000,
335 0x00064029, 0x00000000,
336 0x00024420, 0x00000183,
337 0x5c01401a, 0x0000595c,
338 0x82000015, 0x00002000,
339 0x16200011, 0x00000000,
340 0x82000015, 0x00000010,
341 0x16200011, 0x00000000,
342 0x82000015, 0x00000010,
343 0x16200011, 0x00000000,
344}; /* 104 WoL instructions */
345#define FIRMWARE_WOL_SIZE 104
346#endif
diff --git a/drivers/net/starfire_firmware.pl b/drivers/net/starfire_firmware.pl
deleted file mode 100644
index 0c82b80e1074..000000000000
--- a/drivers/net/starfire_firmware.pl
+++ /dev/null
@@ -1,31 +0,0 @@
1#!/usr/bin/perl
2
3# This script can be used to generate a new starfire_firmware.h
4# from GFP_RX.DAT and GFP_TX.DAT, files included with the DDK
5# and also with the Novell drivers.
6
7open FW, "GFP_RX.DAT" || die;
8open FWH, ">starfire_firmware.h" || die;
9
10printf(FWH "static u32 firmware_rx[] = {\n");
11$counter = 0;
12while ($foo = <FW>) {
13 chomp;
14 printf(FWH " 0x%s, 0x0000%s,\n", substr($foo, 4, 8), substr($foo, 0, 4));
15 $counter++;
16}
17
18close FW;
19open FW, "GFP_TX.DAT" || die;
20
21printf(FWH "};\t/* %d Rx instructions */\n#define FIRMWARE_RX_SIZE %d\n\nstatic u32 firmware_tx[] = {\n", $counter, $counter);
22$counter = 0;
23while ($foo = <FW>) {
24 chomp;
25 printf(FWH " 0x%s, 0x0000%s,\n", substr($foo, 4, 8), substr($foo, 0, 4));
26 $counter++;
27}
28
29close FW;
30printf(FWH "};\t/* %d Tx instructions */\n#define FIRMWARE_TX_SIZE %d\n", $counter, $counter);
31close(FWH);
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 04ae1e86aeaa..5e2dbaee125b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -40,6 +40,7 @@
40#include <linux/workqueue.h> 40#include <linux/workqueue.h>
41#include <linux/prefetch.h> 41#include <linux/prefetch.h>
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <linux/firmware.h>
43 44
44#include <net/checksum.h> 45#include <net/checksum.h>
45#include <net/ip.h> 46#include <net/ip.h>
@@ -137,6 +138,10 @@
137 138
138#define TG3_NUM_TEST 6 139#define TG3_NUM_TEST 6
139 140
141#define FIRMWARE_TG3 "tigon/tg3.bin"
142#define FIRMWARE_TG3TSO "tigon/tg3_tso.bin"
143#define FIRMWARE_TG3TSO5 "tigon/tg3_tso5.bin"
144
140static char version[] __devinitdata = 145static char version[] __devinitdata =
141 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 146 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
142 147
@@ -144,6 +149,10 @@ MODULE_AUTHOR("David S. Miller (davem@redhat.com) and Jeff Garzik (jgarzik@pobox
144MODULE_DESCRIPTION("Broadcom Tigon3 ethernet driver"); 149MODULE_DESCRIPTION("Broadcom Tigon3 ethernet driver");
145MODULE_LICENSE("GPL"); 150MODULE_LICENSE("GPL");
146MODULE_VERSION(DRV_MODULE_VERSION); 151MODULE_VERSION(DRV_MODULE_VERSION);
152MODULE_FIRMWARE(FIRMWARE_TG3);
153MODULE_FIRMWARE(FIRMWARE_TG3TSO);
154MODULE_FIRMWARE(FIRMWARE_TG3TSO5);
155
147 156
148static int tg3_debug = -1; /* -1 == use TG3_DEF_MSG_ENABLE as value */ 157static int tg3_debug = -1; /* -1 == use TG3_DEF_MSG_ENABLE as value */
149module_param(tg3_debug, int, 0); 158module_param(tg3_debug, int, 0);
@@ -6205,130 +6214,6 @@ static int tg3_halt(struct tg3 *tp, int kind, int silent)
6205 return 0; 6214 return 0;
6206} 6215}
6207 6216
6208#define TG3_FW_RELEASE_MAJOR 0x0
6209#define TG3_FW_RELASE_MINOR 0x0
6210#define TG3_FW_RELEASE_FIX 0x0
6211#define TG3_FW_START_ADDR 0x08000000
6212#define TG3_FW_TEXT_ADDR 0x08000000
6213#define TG3_FW_TEXT_LEN 0x9c0
6214#define TG3_FW_RODATA_ADDR 0x080009c0
6215#define TG3_FW_RODATA_LEN 0x60
6216#define TG3_FW_DATA_ADDR 0x08000a40
6217#define TG3_FW_DATA_LEN 0x20
6218#define TG3_FW_SBSS_ADDR 0x08000a60
6219#define TG3_FW_SBSS_LEN 0xc
6220#define TG3_FW_BSS_ADDR 0x08000a70
6221#define TG3_FW_BSS_LEN 0x10
6222
6223static const u32 tg3FwText[(TG3_FW_TEXT_LEN / sizeof(u32)) + 1] = {
6224 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c1d0800,
6225 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100000, 0x0e000018, 0x00000000,
6226 0x0000000d, 0x3c1d0800, 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100034,
6227 0x0e00021c, 0x00000000, 0x0000000d, 0x00000000, 0x00000000, 0x00000000,
6228 0x27bdffe0, 0x3c1cc000, 0xafbf0018, 0xaf80680c, 0x0e00004c, 0x241b2105,
6229 0x97850000, 0x97870002, 0x9782002c, 0x9783002e, 0x3c040800, 0x248409c0,
6230 0xafa00014, 0x00021400, 0x00621825, 0x00052c00, 0xafa30010, 0x8f860010,
6231 0x00e52825, 0x0e000060, 0x24070102, 0x3c02ac00, 0x34420100, 0x3c03ac01,
6232 0x34630100, 0xaf820490, 0x3c02ffff, 0xaf820494, 0xaf830498, 0xaf82049c,
6233 0x24020001, 0xaf825ce0, 0x0e00003f, 0xaf825d00, 0x0e000140, 0x00000000,
6234 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x2402ffff, 0xaf825404, 0x8f835400,
6235 0x34630400, 0xaf835400, 0xaf825404, 0x3c020800, 0x24420034, 0xaf82541c,
6236 0x03e00008, 0xaf805400, 0x00000000, 0x00000000, 0x3c020800, 0x34423000,
6237 0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac220a64,
6238 0x24020040, 0x3c010800, 0xac220a68, 0x3c010800, 0xac200a60, 0xac600000,
6239 0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
6240 0x00804821, 0x8faa0010, 0x3c020800, 0x8c420a60, 0x3c040800, 0x8c840a68,
6241 0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac230a60, 0x14400003,
6242 0x00004021, 0x3c010800, 0xac200a60, 0x3c020800, 0x8c420a60, 0x3c030800,
6243 0x8c630a64, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
6244 0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c420a60,
6245 0x3c030800, 0x8c630a64, 0x8f84680c, 0x00021140, 0x00431021, 0xac440008,
6246 0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
6247 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6249 0, 0, 0, 0, 0, 0,
6250 0x02000008, 0x00000000, 0x0a0001e3, 0x3c0a0001, 0x0a0001e3, 0x3c0a0002,
6251 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6252 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6253 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6254 0x0a0001e3, 0x3c0a0007, 0x0a0001e3, 0x3c0a0008, 0x0a0001e3, 0x3c0a0009,
6255 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x3c0a000b,
6256 0x0a0001e3, 0x3c0a000c, 0x0a0001e3, 0x3c0a000d, 0x0a0001e3, 0x00000000,
6257 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x3c0a000e, 0x0a0001e3, 0x00000000,
6258 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6259 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6260 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x3c0a0013, 0x0a0001e3, 0x3c0a0014,
6261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6264 0x27bdffe0, 0x00001821, 0x00001021, 0xafbf0018, 0xafb10014, 0xafb00010,
6265 0x3c010800, 0x00220821, 0xac200a70, 0x3c010800, 0x00220821, 0xac200a74,
6266 0x3c010800, 0x00220821, 0xac200a78, 0x24630001, 0x1860fff5, 0x2442000c,
6267 0x24110001, 0x8f906810, 0x32020004, 0x14400005, 0x24040001, 0x3c020800,
6268 0x8c420a78, 0x18400003, 0x00002021, 0x0e000182, 0x00000000, 0x32020001,
6269 0x10400003, 0x00000000, 0x0e000169, 0x00000000, 0x0a000153, 0xaf915028,
6270 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c050800,
6271 0x8ca50a70, 0x3c060800, 0x8cc60a80, 0x3c070800, 0x8ce70a78, 0x27bdffe0,
6272 0x3c040800, 0x248409d0, 0xafbf0018, 0xafa00010, 0x0e000060, 0xafa00014,
6273 0x0e00017b, 0x00002021, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x24020001,
6274 0x8f836810, 0x00821004, 0x00021027, 0x00621824, 0x03e00008, 0xaf836810,
6275 0x27bdffd8, 0xafbf0024, 0x1080002e, 0xafb00020, 0x8f825cec, 0xafa20018,
6276 0x8f825cec, 0x3c100800, 0x26100a78, 0xafa2001c, 0x34028000, 0xaf825cec,
6277 0x8e020000, 0x18400016, 0x00000000, 0x3c020800, 0x94420a74, 0x8fa3001c,
6278 0x000221c0, 0xac830004, 0x8fa2001c, 0x3c010800, 0x0e000201, 0xac220a74,
6279 0x10400005, 0x00000000, 0x8e020000, 0x24420001, 0x0a0001df, 0xae020000,
6280 0x3c020800, 0x8c420a70, 0x00021c02, 0x000321c0, 0x0a0001c5, 0xafa2001c,
6281 0x0e000201, 0x00000000, 0x1040001f, 0x00000000, 0x8e020000, 0x8fa3001c,
6282 0x24420001, 0x3c010800, 0xac230a70, 0x3c010800, 0xac230a74, 0x0a0001df,
6283 0xae020000, 0x3c100800, 0x26100a78, 0x8e020000, 0x18400028, 0x00000000,
6284 0x0e000201, 0x00000000, 0x14400024, 0x00000000, 0x8e020000, 0x3c030800,
6285 0x8c630a70, 0x2442ffff, 0xafa3001c, 0x18400006, 0xae020000, 0x00031402,
6286 0x000221c0, 0x8c820004, 0x3c010800, 0xac220a70, 0x97a2001e, 0x2442ff00,
6287 0x2c420300, 0x1440000b, 0x24024000, 0x3c040800, 0x248409dc, 0xafa00010,
6288 0xafa00014, 0x8fa6001c, 0x24050008, 0x0e000060, 0x00003821, 0x0a0001df,
6289 0x00000000, 0xaf825cf8, 0x3c020800, 0x8c420a40, 0x8fa3001c, 0x24420001,
6290 0xaf835cf8, 0x3c010800, 0xac220a40, 0x8fbf0024, 0x8fb00020, 0x03e00008,
6291 0x27bd0028, 0x27bdffe0, 0x3c040800, 0x248409e8, 0x00002821, 0x00003021,
6292 0x00003821, 0xafbf0018, 0xafa00010, 0x0e000060, 0xafa00014, 0x8fbf0018,
6293 0x03e00008, 0x27bd0020, 0x8f82680c, 0x8f85680c, 0x00021827, 0x0003182b,
6294 0x00031823, 0x00431024, 0x00441021, 0x00a2282b, 0x10a00006, 0x00000000,
6295 0x00401821, 0x8f82680c, 0x0043102b, 0x1440fffd, 0x00000000, 0x03e00008,
6296 0x00000000, 0x3c040800, 0x8c840000, 0x3c030800, 0x8c630a40, 0x0064102b,
6297 0x54400002, 0x00831023, 0x00641023, 0x2c420008, 0x03e00008, 0x38420001,
6298 0x27bdffe0, 0x00802821, 0x3c040800, 0x24840a00, 0x00003021, 0x00003821,
6299 0xafbf0018, 0xafa00010, 0x0e000060, 0xafa00014, 0x0a000216, 0x00000000,
6300 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x00000000, 0x27bdffe0, 0x3c1cc000,
6301 0xafbf0018, 0x0e00004c, 0xaf80680c, 0x3c040800, 0x24840a10, 0x03802821,
6302 0x00003021, 0x00003821, 0xafa00010, 0x0e000060, 0xafa00014, 0x2402ffff,
6303 0xaf825404, 0x3c0200aa, 0x0e000234, 0xaf825434, 0x8fbf0018, 0x03e00008,
6304 0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe8, 0xafb00010,
6305 0x24100001, 0xafbf0014, 0x3c01c003, 0xac200000, 0x8f826810, 0x30422000,
6306 0x10400003, 0x00000000, 0x0e000246, 0x00000000, 0x0a00023a, 0xaf905428,
6307 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdfff8, 0x8f845d0c,
6308 0x3c0200ff, 0x3c030800, 0x8c630a50, 0x3442fff8, 0x00821024, 0x1043001e,
6309 0x3c0500ff, 0x34a5fff8, 0x3c06c003, 0x3c074000, 0x00851824, 0x8c620010,
6310 0x3c010800, 0xac230a50, 0x30420008, 0x10400005, 0x00871025, 0x8cc20000,
6311 0x24420001, 0xacc20000, 0x00871025, 0xaf825d0c, 0x8fa20000, 0x24420001,
6312 0xafa20000, 0x8fa20000, 0x8fa20000, 0x24420001, 0xafa20000, 0x8fa20000,
6313 0x8f845d0c, 0x3c030800, 0x8c630a50, 0x00851024, 0x1443ffe8, 0x00851824,
6314 0x27bd0008, 0x03e00008, 0x00000000, 0x00000000, 0x00000000
6315};
6316
6317static const u32 tg3FwRodata[(TG3_FW_RODATA_LEN / sizeof(u32)) + 1] = {
6318 0x35373031, 0x726c7341, 0x00000000, 0x00000000, 0x53774576, 0x656e7430,
6319 0x00000000, 0x726c7045, 0x76656e74, 0x31000000, 0x556e6b6e, 0x45766e74,
6320 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
6321 0x00000000, 0x00000000, 0x4d61696e, 0x43707542, 0x00000000, 0x00000000,
6322 0x00000000
6323};
6324
6325#if 0 /* All zeros, don't eat up space with it. */
6326u32 tg3FwData[(TG3_FW_DATA_LEN / sizeof(u32)) + 1] = {
6327 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
6328 0x00000000, 0x00000000, 0x00000000, 0x00000000
6329};
6330#endif
6331
6332#define RX_CPU_SCRATCH_BASE 0x30000 6217#define RX_CPU_SCRATCH_BASE 0x30000
6333#define RX_CPU_SCRATCH_SIZE 0x04000 6218#define RX_CPU_SCRATCH_SIZE 0x04000
6334#define TX_CPU_SCRATCH_BASE 0x34000 6219#define TX_CPU_SCRATCH_BASE 0x34000
@@ -6383,15 +6268,9 @@ static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
6383} 6268}
6384 6269
6385struct fw_info { 6270struct fw_info {
6386 unsigned int text_base; 6271 unsigned int fw_base;
6387 unsigned int text_len; 6272 unsigned int fw_len;
6388 const u32 *text_data; 6273 const __be32 *fw_data;
6389 unsigned int rodata_base;
6390 unsigned int rodata_len;
6391 const u32 *rodata_data;
6392 unsigned int data_base;
6393 unsigned int data_len;
6394 const u32 *data_data;
6395}; 6274};
6396 6275
6397/* tp->lock is held. */ 6276/* tp->lock is held. */
@@ -6428,24 +6307,11 @@ static int tg3_load_firmware_cpu(struct tg3 *tp, u32 cpu_base, u32 cpu_scratch_b
6428 write_op(tp, cpu_scratch_base + i, 0); 6307 write_op(tp, cpu_scratch_base + i, 0);
6429 tw32(cpu_base + CPU_STATE, 0xffffffff); 6308 tw32(cpu_base + CPU_STATE, 0xffffffff);
6430 tw32(cpu_base + CPU_MODE, tr32(cpu_base+CPU_MODE)|CPU_MODE_HALT); 6309 tw32(cpu_base + CPU_MODE, tr32(cpu_base+CPU_MODE)|CPU_MODE_HALT);
6431 for (i = 0; i < (info->text_len / sizeof(u32)); i++) 6310 for (i = 0; i < (info->fw_len / sizeof(u32)); i++)
6432 write_op(tp, (cpu_scratch_base +
6433 (info->text_base & 0xffff) +
6434 (i * sizeof(u32))),
6435 (info->text_data ?
6436 info->text_data[i] : 0));
6437 for (i = 0; i < (info->rodata_len / sizeof(u32)); i++)
6438 write_op(tp, (cpu_scratch_base +
6439 (info->rodata_base & 0xffff) +
6440 (i * sizeof(u32))),
6441 (info->rodata_data ?
6442 info->rodata_data[i] : 0));
6443 for (i = 0; i < (info->data_len / sizeof(u32)); i++)
6444 write_op(tp, (cpu_scratch_base + 6311 write_op(tp, (cpu_scratch_base +
6445 (info->data_base & 0xffff) + 6312 (info->fw_base & 0xffff) +
6446 (i * sizeof(u32))), 6313 (i * sizeof(u32))),
6447 (info->data_data ? 6314 be32_to_cpu(info->fw_data[i]));
6448 info->data_data[i] : 0));
6449 6315
6450 err = 0; 6316 err = 0;
6451 6317
@@ -6457,17 +6323,20 @@ out:
6457static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp) 6323static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
6458{ 6324{
6459 struct fw_info info; 6325 struct fw_info info;
6326 const __be32 *fw_data;
6460 int err, i; 6327 int err, i;
6461 6328
6462 info.text_base = TG3_FW_TEXT_ADDR; 6329 fw_data = (void *)tp->fw->data;
6463 info.text_len = TG3_FW_TEXT_LEN; 6330
6464 info.text_data = &tg3FwText[0]; 6331 /* Firmware blob starts with version numbers, followed by
6465 info.rodata_base = TG3_FW_RODATA_ADDR; 6332 start address and length. We are setting complete length.
6466 info.rodata_len = TG3_FW_RODATA_LEN; 6333 length = end_address_of_bss - start_address_of_text.
6467 info.rodata_data = &tg3FwRodata[0]; 6334 Remainder is the blob to be loaded contiguously
6468 info.data_base = TG3_FW_DATA_ADDR; 6335 from start address. */
6469 info.data_len = TG3_FW_DATA_LEN; 6336
6470 info.data_data = NULL; 6337 info.fw_base = be32_to_cpu(fw_data[1]);
6338 info.fw_len = tp->fw->size - 12;
6339 info.fw_data = &fw_data[3];
6471 6340
6472 err = tg3_load_firmware_cpu(tp, RX_CPU_BASE, 6341 err = tg3_load_firmware_cpu(tp, RX_CPU_BASE,
6473 RX_CPU_SCRATCH_BASE, RX_CPU_SCRATCH_SIZE, 6342 RX_CPU_SCRATCH_BASE, RX_CPU_SCRATCH_SIZE,
@@ -6483,21 +6352,21 @@ static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
6483 6352
6484 /* Now startup only the RX cpu. */ 6353 /* Now startup only the RX cpu. */
6485 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff); 6354 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff);
6486 tw32_f(RX_CPU_BASE + CPU_PC, TG3_FW_TEXT_ADDR); 6355 tw32_f(RX_CPU_BASE + CPU_PC, info.fw_base);
6487 6356
6488 for (i = 0; i < 5; i++) { 6357 for (i = 0; i < 5; i++) {
6489 if (tr32(RX_CPU_BASE + CPU_PC) == TG3_FW_TEXT_ADDR) 6358 if (tr32(RX_CPU_BASE + CPU_PC) == info.fw_base)
6490 break; 6359 break;
6491 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff); 6360 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff);
6492 tw32(RX_CPU_BASE + CPU_MODE, CPU_MODE_HALT); 6361 tw32(RX_CPU_BASE + CPU_MODE, CPU_MODE_HALT);
6493 tw32_f(RX_CPU_BASE + CPU_PC, TG3_FW_TEXT_ADDR); 6362 tw32_f(RX_CPU_BASE + CPU_PC, info.fw_base);
6494 udelay(1000); 6363 udelay(1000);
6495 } 6364 }
6496 if (i >= 5) { 6365 if (i >= 5) {
6497 printk(KERN_ERR PFX "tg3_load_firmware fails for %s " 6366 printk(KERN_ERR PFX "tg3_load_firmware fails for %s "
6498 "to set RX CPU PC, is %08x should be %08x\n", 6367 "to set RX CPU PC, is %08x should be %08x\n",
6499 tp->dev->name, tr32(RX_CPU_BASE + CPU_PC), 6368 tp->dev->name, tr32(RX_CPU_BASE + CPU_PC),
6500 TG3_FW_TEXT_ADDR); 6369 info.fw_base);
6501 return -ENODEV; 6370 return -ENODEV;
6502 } 6371 }
6503 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff); 6372 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff);
@@ -6506,547 +6375,36 @@ static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
6506 return 0; 6375 return 0;
6507} 6376}
6508 6377
6509
6510#define TG3_TSO_FW_RELEASE_MAJOR 0x1
6511#define TG3_TSO_FW_RELASE_MINOR 0x6
6512#define TG3_TSO_FW_RELEASE_FIX 0x0
6513#define TG3_TSO_FW_START_ADDR 0x08000000
6514#define TG3_TSO_FW_TEXT_ADDR 0x08000000
6515#define TG3_TSO_FW_TEXT_LEN 0x1aa0
6516#define TG3_TSO_FW_RODATA_ADDR 0x08001aa0
6517#define TG3_TSO_FW_RODATA_LEN 0x60
6518#define TG3_TSO_FW_DATA_ADDR 0x08001b20
6519#define TG3_TSO_FW_DATA_LEN 0x30
6520#define TG3_TSO_FW_SBSS_ADDR 0x08001b50
6521#define TG3_TSO_FW_SBSS_LEN 0x2c
6522#define TG3_TSO_FW_BSS_ADDR 0x08001b80
6523#define TG3_TSO_FW_BSS_LEN 0x894
6524
6525static const u32 tg3TsoFwText[(TG3_TSO_FW_TEXT_LEN / 4) + 1] = {
6526 0x0e000003, 0x00000000, 0x08001b24, 0x00000000, 0x10000003, 0x00000000,
6527 0x0000000d, 0x0000000d, 0x3c1d0800, 0x37bd4000, 0x03a0f021, 0x3c100800,
6528 0x26100000, 0x0e000010, 0x00000000, 0x0000000d, 0x27bdffe0, 0x3c04fefe,
6529 0xafbf0018, 0x0e0005d8, 0x34840002, 0x0e000668, 0x00000000, 0x3c030800,
6530 0x90631b68, 0x24020002, 0x3c040800, 0x24841aac, 0x14620003, 0x24050001,
6531 0x3c040800, 0x24841aa0, 0x24060006, 0x00003821, 0xafa00010, 0x0e00067c,
6532 0xafa00014, 0x8f625c50, 0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001,
6533 0xaf625c90, 0x2402ffff, 0x0e000034, 0xaf625404, 0x8fbf0018, 0x03e00008,
6534 0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0xafbf001c,
6535 0xafb20018, 0xafb10014, 0x0e00005b, 0xafb00010, 0x24120002, 0x24110001,
6536 0x8f706820, 0x32020100, 0x10400003, 0x00000000, 0x0e0000bb, 0x00000000,
6537 0x8f706820, 0x32022000, 0x10400004, 0x32020001, 0x0e0001f0, 0x24040001,
6538 0x32020001, 0x10400003, 0x00000000, 0x0e0000a3, 0x00000000, 0x3c020800,
6539 0x90421b98, 0x14520003, 0x00000000, 0x0e0004c0, 0x00000000, 0x0a00003c,
6540 0xaf715028, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008,
6541 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x24841ac0, 0x00002821, 0x00003021,
6542 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00067c, 0xafa00014, 0x3c040800,
6543 0x248423d8, 0xa4800000, 0x3c010800, 0xa0201b98, 0x3c010800, 0xac201b9c,
6544 0x3c010800, 0xac201ba0, 0x3c010800, 0xac201ba4, 0x3c010800, 0xac201bac,
6545 0x3c010800, 0xac201bb8, 0x3c010800, 0xac201bbc, 0x8f624434, 0x3c010800,
6546 0xac221b88, 0x8f624438, 0x3c010800, 0xac221b8c, 0x8f624410, 0xac80f7a8,
6547 0x3c010800, 0xac201b84, 0x3c010800, 0xac2023e0, 0x3c010800, 0xac2023c8,
6548 0x3c010800, 0xac2023cc, 0x3c010800, 0xac202400, 0x3c010800, 0xac221b90,
6549 0x8f620068, 0x24030007, 0x00021702, 0x10430005, 0x00000000, 0x8f620068,
6550 0x00021702, 0x14400004, 0x24020001, 0x3c010800, 0x0a000097, 0xac20240c,
6551 0xac820034, 0x3c040800, 0x24841acc, 0x3c050800, 0x8ca5240c, 0x00003021,
6552 0x00003821, 0xafa00010, 0x0e00067c, 0xafa00014, 0x8fbf0018, 0x03e00008,
6553 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x24841ad8, 0x00002821, 0x00003021,
6554 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00067c, 0xafa00014, 0x0e00005b,
6555 0x00000000, 0x0e0000b4, 0x00002021, 0x8fbf0018, 0x03e00008, 0x27bd0020,
6556 0x24020001, 0x8f636820, 0x00821004, 0x00021027, 0x00621824, 0x03e00008,
6557 0xaf636820, 0x27bdffd0, 0xafbf002c, 0xafb60028, 0xafb50024, 0xafb40020,
6558 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x8f675c5c, 0x3c030800,
6559 0x24631bbc, 0x8c620000, 0x14470005, 0x3c0200ff, 0x3c020800, 0x90421b98,
6560 0x14400119, 0x3c0200ff, 0x3442fff8, 0x00e28824, 0xac670000, 0x00111902,
6561 0x306300ff, 0x30e20003, 0x000211c0, 0x00622825, 0x00a04021, 0x00071602,
6562 0x3c030800, 0x90631b98, 0x3044000f, 0x14600036, 0x00804821, 0x24020001,
6563 0x3c010800, 0xa0221b98, 0x00051100, 0x00821025, 0x3c010800, 0xac201b9c,
6564 0x3c010800, 0xac201ba0, 0x3c010800, 0xac201ba4, 0x3c010800, 0xac201bac,
6565 0x3c010800, 0xac201bb8, 0x3c010800, 0xac201bb0, 0x3c010800, 0xac201bb4,
6566 0x3c010800, 0xa42223d8, 0x9622000c, 0x30437fff, 0x3c010800, 0xa4222410,
6567 0x30428000, 0x3c010800, 0xa4231bc6, 0x10400005, 0x24020001, 0x3c010800,
6568 0xac2223f4, 0x0a000102, 0x2406003e, 0x24060036, 0x3c010800, 0xac2023f4,
6569 0x9622000a, 0x3c030800, 0x94631bc6, 0x3c010800, 0xac2023f0, 0x3c010800,
6570 0xac2023f8, 0x00021302, 0x00021080, 0x00c21021, 0x00621821, 0x3c010800,
6571 0xa42223d0, 0x3c010800, 0x0a000115, 0xa4231b96, 0x9622000c, 0x3c010800,
6572 0xa42223ec, 0x3c040800, 0x24841b9c, 0x8c820000, 0x00021100, 0x3c010800,
6573 0x00220821, 0xac311bc8, 0x8c820000, 0x00021100, 0x3c010800, 0x00220821,
6574 0xac271bcc, 0x8c820000, 0x25030001, 0x306601ff, 0x00021100, 0x3c010800,
6575 0x00220821, 0xac261bd0, 0x8c820000, 0x00021100, 0x3c010800, 0x00220821,
6576 0xac291bd4, 0x96230008, 0x3c020800, 0x8c421bac, 0x00432821, 0x3c010800,
6577 0xac251bac, 0x9622000a, 0x30420004, 0x14400018, 0x00061100, 0x8f630c14,
6578 0x3063000f, 0x2c620002, 0x1440000b, 0x3c02c000, 0x8f630c14, 0x3c020800,
6579 0x8c421b40, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b40, 0x2c620002,
6580 0x1040fff7, 0x3c02c000, 0x00e21825, 0xaf635c5c, 0x8f625c50, 0x30420002,
6581 0x10400014, 0x00000000, 0x0a000147, 0x00000000, 0x3c030800, 0x8c631b80,
6582 0x3c040800, 0x94841b94, 0x01221025, 0x3c010800, 0xa42223da, 0x24020001,
6583 0x3c010800, 0xac221bb8, 0x24630001, 0x0085202a, 0x3c010800, 0x10800003,
6584 0xac231b80, 0x3c010800, 0xa4251b94, 0x3c060800, 0x24c61b9c, 0x8cc20000,
6585 0x24420001, 0xacc20000, 0x28420080, 0x14400005, 0x00000000, 0x0e000656,
6586 0x24040002, 0x0a0001e6, 0x00000000, 0x3c020800, 0x8c421bb8, 0x10400078,
6587 0x24020001, 0x3c050800, 0x90a51b98, 0x14a20072, 0x00000000, 0x3c150800,
6588 0x96b51b96, 0x3c040800, 0x8c841bac, 0x32a3ffff, 0x0083102a, 0x1440006c,
6589 0x00000000, 0x14830003, 0x00000000, 0x3c010800, 0xac2523f0, 0x1060005c,
6590 0x00009021, 0x24d60004, 0x0060a021, 0x24d30014, 0x8ec20000, 0x00028100,
6591 0x3c110800, 0x02308821, 0x0e000625, 0x8e311bc8, 0x00402821, 0x10a00054,
6592 0x00000000, 0x9628000a, 0x31020040, 0x10400005, 0x2407180c, 0x8e22000c,
6593 0x2407188c, 0x00021400, 0xaca20018, 0x3c030800, 0x00701821, 0x8c631bd0,
6594 0x3c020800, 0x00501021, 0x8c421bd4, 0x00031d00, 0x00021400, 0x00621825,
6595 0xaca30014, 0x8ec30004, 0x96220008, 0x00432023, 0x3242ffff, 0x3083ffff,
6596 0x00431021, 0x0282102a, 0x14400002, 0x02b23023, 0x00803021, 0x8e620000,
6597 0x30c4ffff, 0x00441021, 0xae620000, 0x8e220000, 0xaca20000, 0x8e220004,
6598 0x8e63fff4, 0x00431021, 0xaca20004, 0xa4a6000e, 0x8e62fff4, 0x00441021,
6599 0xae62fff4, 0x96230008, 0x0043102a, 0x14400005, 0x02469021, 0x8e62fff0,
6600 0xae60fff4, 0x24420001, 0xae62fff0, 0xaca00008, 0x3242ffff, 0x14540008,
6601 0x24020305, 0x31020080, 0x54400001, 0x34e70010, 0x24020905, 0xa4a2000c,
6602 0x0a0001cb, 0x34e70020, 0xa4a2000c, 0x3c020800, 0x8c4223f0, 0x10400003,
6603 0x3c024b65, 0x0a0001d3, 0x34427654, 0x3c02b49a, 0x344289ab, 0xaca2001c,
6604 0x30e2ffff, 0xaca20010, 0x0e0005a2, 0x00a02021, 0x3242ffff, 0x0054102b,
6605 0x1440ffa9, 0x00000000, 0x24020002, 0x3c010800, 0x0a0001e6, 0xa0221b98,
6606 0x8ec2083c, 0x24420001, 0x0a0001e6, 0xaec2083c, 0x0e0004c0, 0x00000000,
6607 0x8fbf002c, 0x8fb60028, 0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018,
6608 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0030, 0x27bdffd0, 0xafbf0028,
6609 0xafb30024, 0xafb20020, 0xafb1001c, 0xafb00018, 0x8f725c9c, 0x3c0200ff,
6610 0x3442fff8, 0x3c070800, 0x24e71bb4, 0x02428824, 0x9623000e, 0x8ce20000,
6611 0x00431021, 0xace20000, 0x8e220010, 0x30420020, 0x14400011, 0x00809821,
6612 0x0e00063b, 0x02202021, 0x3c02c000, 0x02421825, 0xaf635c9c, 0x8f625c90,
6613 0x30420002, 0x1040011e, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002,
6614 0x10400119, 0x00000000, 0x0a00020d, 0x00000000, 0x8e240008, 0x8e230014,
6615 0x00041402, 0x000231c0, 0x00031502, 0x304201ff, 0x2442ffff, 0x3042007f,
6616 0x00031942, 0x30637800, 0x00021100, 0x24424000, 0x00624821, 0x9522000a,
6617 0x3084ffff, 0x30420008, 0x104000b0, 0x000429c0, 0x3c020800, 0x8c422400,
6618 0x14400024, 0x24c50008, 0x94c20014, 0x3c010800, 0xa42223d0, 0x8cc40010,
6619 0x00041402, 0x3c010800, 0xa42223d2, 0x3c010800, 0xa42423d4, 0x94c2000e,
6620 0x3083ffff, 0x00431023, 0x3c010800, 0xac222408, 0x94c2001a, 0x3c010800,
6621 0xac262400, 0x3c010800, 0xac322404, 0x3c010800, 0xac2223fc, 0x3c02c000,
6622 0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x104000e5, 0x00000000,
6623 0xaf635c9c, 0x8f625c90, 0x30420002, 0x104000e0, 0x00000000, 0x0a000246,
6624 0x00000000, 0x94c2000e, 0x3c030800, 0x946323d4, 0x00434023, 0x3103ffff,
6625 0x2c620008, 0x1040001c, 0x00000000, 0x94c20014, 0x24420028, 0x00a22821,
6626 0x00031042, 0x1840000b, 0x00002021, 0x24e60848, 0x00403821, 0x94a30000,
6627 0x8cc20000, 0x24840001, 0x00431021, 0xacc20000, 0x0087102a, 0x1440fff9,
6628 0x24a50002, 0x31020001, 0x1040001f, 0x3c024000, 0x3c040800, 0x248423fc,
6629 0xa0a00001, 0x94a30000, 0x8c820000, 0x00431021, 0x0a000285, 0xac820000,
6630 0x8f626800, 0x3c030010, 0x00431024, 0x10400009, 0x00000000, 0x94c2001a,
6631 0x3c030800, 0x8c6323fc, 0x00431021, 0x3c010800, 0xac2223fc, 0x0a000286,
6632 0x3c024000, 0x94c2001a, 0x94c4001c, 0x3c030800, 0x8c6323fc, 0x00441023,
6633 0x00621821, 0x3c010800, 0xac2323fc, 0x3c024000, 0x02421825, 0xaf635c9c,
6634 0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000, 0x9522000a, 0x30420010,
6635 0x1040009b, 0x00000000, 0x3c030800, 0x946323d4, 0x3c070800, 0x24e72400,
6636 0x8ce40000, 0x8f626800, 0x24630030, 0x00832821, 0x3c030010, 0x00431024,
6637 0x1440000a, 0x00000000, 0x94a20004, 0x3c040800, 0x8c842408, 0x3c030800,
6638 0x8c6323fc, 0x00441023, 0x00621821, 0x3c010800, 0xac2323fc, 0x3c040800,
6639 0x8c8423fc, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402, 0x00822021,
6640 0x00041027, 0xa4a20006, 0x3c030800, 0x8c632404, 0x3c0200ff, 0x3442fff8,
6641 0x00628824, 0x96220008, 0x24050001, 0x24034000, 0x000231c0, 0x00801021,
6642 0xa4c2001a, 0xa4c0001c, 0xace00000, 0x3c010800, 0xac251b60, 0xaf635cb8,
6643 0x8f625cb0, 0x30420002, 0x10400003, 0x00000000, 0x3c010800, 0xac201b60,
6644 0x8e220008, 0xaf625cb8, 0x8f625cb0, 0x30420002, 0x10400003, 0x00000000,
6645 0x3c010800, 0xac201b60, 0x3c020800, 0x8c421b60, 0x1040ffec, 0x00000000,
6646 0x3c040800, 0x0e00063b, 0x8c842404, 0x0a00032a, 0x00000000, 0x3c030800,
6647 0x90631b98, 0x24020002, 0x14620003, 0x3c034b65, 0x0a0002e1, 0x00008021,
6648 0x8e22001c, 0x34637654, 0x10430002, 0x24100002, 0x24100001, 0x00c02021,
6649 0x0e000350, 0x02003021, 0x24020003, 0x3c010800, 0xa0221b98, 0x24020002,
6650 0x1202000a, 0x24020001, 0x3c030800, 0x8c6323f0, 0x10620006, 0x00000000,
6651 0x3c020800, 0x944223d8, 0x00021400, 0x0a00031f, 0xae220014, 0x3c040800,
6652 0x248423da, 0x94820000, 0x00021400, 0xae220014, 0x3c020800, 0x8c421bbc,
6653 0x3c03c000, 0x3c010800, 0xa0201b98, 0x00431025, 0xaf625c5c, 0x8f625c50,
6654 0x30420002, 0x10400009, 0x00000000, 0x2484f7e2, 0x8c820000, 0x00431025,
6655 0xaf625c5c, 0x8f625c50, 0x30420002, 0x1440fffa, 0x00000000, 0x3c020800,
6656 0x24421b84, 0x8c430000, 0x24630001, 0xac430000, 0x8f630c14, 0x3063000f,
6657 0x2c620002, 0x1440000c, 0x3c024000, 0x8f630c14, 0x3c020800, 0x8c421b40,
6658 0x3063000f, 0x24420001, 0x3c010800, 0xac221b40, 0x2c620002, 0x1040fff7,
6659 0x00000000, 0x3c024000, 0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002,
6660 0x1440fffc, 0x00000000, 0x12600003, 0x00000000, 0x0e0004c0, 0x00000000,
6661 0x8fbf0028, 0x8fb30024, 0x8fb20020, 0x8fb1001c, 0x8fb00018, 0x03e00008,
6662 0x27bd0030, 0x8f634450, 0x3c040800, 0x24841b88, 0x8c820000, 0x00031c02,
6663 0x0043102b, 0x14400007, 0x3c038000, 0x8c840004, 0x8f624450, 0x00021c02,
6664 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444, 0x00431024,
6665 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff, 0x3c024000,
6666 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc, 0x00000000,
6667 0x03e00008, 0x00000000, 0x27bdffe0, 0x00805821, 0x14c00011, 0x256e0008,
6668 0x3c020800, 0x8c4223f4, 0x10400007, 0x24020016, 0x3c010800, 0xa42223d2,
6669 0x2402002a, 0x3c010800, 0x0a000364, 0xa42223d4, 0x8d670010, 0x00071402,
6670 0x3c010800, 0xa42223d2, 0x3c010800, 0xa42723d4, 0x3c040800, 0x948423d4,
6671 0x3c030800, 0x946323d2, 0x95cf0006, 0x3c020800, 0x944223d0, 0x00832023,
6672 0x01e2c023, 0x3065ffff, 0x24a20028, 0x01c24821, 0x3082ffff, 0x14c0001a,
6673 0x01226021, 0x9582000c, 0x3042003f, 0x3c010800, 0xa42223d6, 0x95820004,
6674 0x95830006, 0x3c010800, 0xac2023e4, 0x3c010800, 0xac2023e8, 0x00021400,
6675 0x00431025, 0x3c010800, 0xac221bc0, 0x95220004, 0x3c010800, 0xa4221bc4,
6676 0x95230002, 0x01e51023, 0x0043102a, 0x10400010, 0x24020001, 0x3c010800,
6677 0x0a000398, 0xac2223f8, 0x3c030800, 0x8c6323e8, 0x3c020800, 0x94421bc4,
6678 0x00431021, 0xa5220004, 0x3c020800, 0x94421bc0, 0xa5820004, 0x3c020800,
6679 0x8c421bc0, 0xa5820006, 0x3c020800, 0x8c4223f0, 0x3c0d0800, 0x8dad23e4,
6680 0x3c0a0800, 0x144000e5, 0x8d4a23e8, 0x3c020800, 0x94421bc4, 0x004a1821,
6681 0x3063ffff, 0x0062182b, 0x24020002, 0x10c2000d, 0x01435023, 0x3c020800,
6682 0x944223d6, 0x30420009, 0x10400008, 0x00000000, 0x9582000c, 0x3042fff6,
6683 0xa582000c, 0x3c020800, 0x944223d6, 0x30420009, 0x01a26823, 0x3c020800,
6684 0x8c4223f8, 0x1040004a, 0x01203821, 0x3c020800, 0x944223d2, 0x00004021,
6685 0xa520000a, 0x01e21023, 0xa5220002, 0x3082ffff, 0x00021042, 0x18400008,
6686 0x00003021, 0x00401821, 0x94e20000, 0x25080001, 0x00c23021, 0x0103102a,
6687 0x1440fffb, 0x24e70002, 0x00061c02, 0x30c2ffff, 0x00623021, 0x00061402,
6688 0x00c23021, 0x00c02821, 0x00061027, 0xa522000a, 0x00003021, 0x2527000c,
6689 0x00004021, 0x94e20000, 0x25080001, 0x00c23021, 0x2d020004, 0x1440fffb,
6690 0x24e70002, 0x95220002, 0x00004021, 0x91230009, 0x00442023, 0x01803821,
6691 0x3082ffff, 0xa4e00010, 0x00621821, 0x00021042, 0x18400010, 0x00c33021,
6692 0x00404821, 0x94e20000, 0x24e70002, 0x00c23021, 0x30e2007f, 0x14400006,
6693 0x25080001, 0x8d630000, 0x3c02007f, 0x3442ff80, 0x00625824, 0x25670008,
6694 0x0109102a, 0x1440fff3, 0x00000000, 0x30820001, 0x10400005, 0x00061c02,
6695 0xa0e00001, 0x94e20000, 0x00c23021, 0x00061c02, 0x30c2ffff, 0x00623021,
6696 0x00061402, 0x00c23021, 0x0a00047d, 0x30c6ffff, 0x24020002, 0x14c20081,
6697 0x00000000, 0x3c020800, 0x8c42240c, 0x14400007, 0x00000000, 0x3c020800,
6698 0x944223d2, 0x95230002, 0x01e21023, 0x10620077, 0x00000000, 0x3c020800,
6699 0x944223d2, 0x01e21023, 0xa5220002, 0x3c020800, 0x8c42240c, 0x1040001a,
6700 0x31e3ffff, 0x8dc70010, 0x3c020800, 0x94421b96, 0x00e04021, 0x00072c02,
6701 0x00aa2021, 0x00431023, 0x00823823, 0x00072402, 0x30e2ffff, 0x00823821,
6702 0x00071027, 0xa522000a, 0x3102ffff, 0x3c040800, 0x948423d4, 0x00453023,
6703 0x00e02821, 0x00641823, 0x006d1821, 0x00c33021, 0x00061c02, 0x30c2ffff,
6704 0x0a00047d, 0x00623021, 0x01203821, 0x00004021, 0x3082ffff, 0x00021042,
6705 0x18400008, 0x00003021, 0x00401821, 0x94e20000, 0x25080001, 0x00c23021,
6706 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02, 0x30c2ffff, 0x00623021,
6707 0x00061402, 0x00c23021, 0x00c02821, 0x00061027, 0xa522000a, 0x00003021,
6708 0x2527000c, 0x00004021, 0x94e20000, 0x25080001, 0x00c23021, 0x2d020004,
6709 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021, 0x91230009, 0x00442023,
6710 0x01803821, 0x3082ffff, 0xa4e00010, 0x3c040800, 0x948423d4, 0x00621821,
6711 0x00c33021, 0x00061c02, 0x30c2ffff, 0x00623021, 0x00061c02, 0x3c020800,
6712 0x944223d0, 0x00c34821, 0x00441023, 0x00021fc2, 0x00431021, 0x00021043,
6713 0x18400010, 0x00003021, 0x00402021, 0x94e20000, 0x24e70002, 0x00c23021,
6714 0x30e2007f, 0x14400006, 0x25080001, 0x8d630000, 0x3c02007f, 0x3442ff80,
6715 0x00625824, 0x25670008, 0x0104102a, 0x1440fff3, 0x00000000, 0x3c020800,
6716 0x944223ec, 0x00c23021, 0x3122ffff, 0x00c23021, 0x00061c02, 0x30c2ffff,
6717 0x00623021, 0x00061402, 0x00c23021, 0x00c04021, 0x00061027, 0xa5820010,
6718 0xadc00014, 0x0a00049d, 0xadc00000, 0x8dc70010, 0x00e04021, 0x11400007,
6719 0x00072c02, 0x00aa3021, 0x00061402, 0x30c3ffff, 0x00433021, 0x00061402,
6720 0x00c22821, 0x00051027, 0xa522000a, 0x3c030800, 0x946323d4, 0x3102ffff,
6721 0x01e21021, 0x00433023, 0x00cd3021, 0x00061c02, 0x30c2ffff, 0x00623021,
6722 0x00061402, 0x00c23021, 0x00c04021, 0x00061027, 0xa5820010, 0x3102ffff,
6723 0x00051c00, 0x00431025, 0xadc20010, 0x3c020800, 0x8c4223f4, 0x10400005,
6724 0x2de205eb, 0x14400002, 0x25e2fff2, 0x34028870, 0xa5c20034, 0x3c030800,
6725 0x246323e8, 0x8c620000, 0x24420001, 0xac620000, 0x3c040800, 0x8c8423e4,
6726 0x3c020800, 0x8c421bc0, 0x3303ffff, 0x00832021, 0x00431821, 0x0062102b,
6727 0x3c010800, 0xac2423e4, 0x10400003, 0x2482ffff, 0x3c010800, 0xac2223e4,
6728 0x3c010800, 0xac231bc0, 0x03e00008, 0x27bd0020, 0x27bdffb8, 0x3c050800,
6729 0x24a51b96, 0xafbf0044, 0xafbe0040, 0xafb7003c, 0xafb60038, 0xafb50034,
6730 0xafb40030, 0xafb3002c, 0xafb20028, 0xafb10024, 0xafb00020, 0x94a90000,
6731 0x3c020800, 0x944223d0, 0x3c030800, 0x8c631bb0, 0x3c040800, 0x8c841bac,
6732 0x01221023, 0x0064182a, 0xa7a9001e, 0x106000be, 0xa7a20016, 0x24be0022,
6733 0x97b6001e, 0x24b3001a, 0x24b70016, 0x8fc20000, 0x14400008, 0x00000000,
6734 0x8fc2fff8, 0x97a30016, 0x8fc4fff4, 0x00431021, 0x0082202a, 0x148000b0,
6735 0x00000000, 0x97d50818, 0x32a2ffff, 0x104000a3, 0x00009021, 0x0040a021,
6736 0x00008821, 0x0e000625, 0x00000000, 0x00403021, 0x14c00007, 0x00000000,
6737 0x3c020800, 0x8c4223dc, 0x24420001, 0x3c010800, 0x0a000596, 0xac2223dc,
6738 0x3c100800, 0x02118021, 0x8e101bc8, 0x9608000a, 0x31020040, 0x10400005,
6739 0x2407180c, 0x8e02000c, 0x2407188c, 0x00021400, 0xacc20018, 0x31020080,
6740 0x54400001, 0x34e70010, 0x3c020800, 0x00511021, 0x8c421bd0, 0x3c030800,
6741 0x00711821, 0x8c631bd4, 0x00021500, 0x00031c00, 0x00431025, 0xacc20014,
6742 0x96040008, 0x3242ffff, 0x00821021, 0x0282102a, 0x14400002, 0x02b22823,
6743 0x00802821, 0x8e020000, 0x02459021, 0xacc20000, 0x8e020004, 0x00c02021,
6744 0x26310010, 0xac820004, 0x30e2ffff, 0xac800008, 0xa485000e, 0xac820010,
6745 0x24020305, 0x0e0005a2, 0xa482000c, 0x3242ffff, 0x0054102b, 0x1440ffc5,
6746 0x3242ffff, 0x0a00058e, 0x00000000, 0x8e620000, 0x8e63fffc, 0x0043102a,
6747 0x10400067, 0x00000000, 0x8e62fff0, 0x00028900, 0x3c100800, 0x02118021,
6748 0x0e000625, 0x8e101bc8, 0x00403021, 0x14c00005, 0x00000000, 0x8e62082c,
6749 0x24420001, 0x0a000596, 0xae62082c, 0x9608000a, 0x31020040, 0x10400005,
6750 0x2407180c, 0x8e02000c, 0x2407188c, 0x00021400, 0xacc20018, 0x3c020800,
6751 0x00511021, 0x8c421bd0, 0x3c030800, 0x00711821, 0x8c631bd4, 0x00021500,
6752 0x00031c00, 0x00431025, 0xacc20014, 0x8e63fff4, 0x96020008, 0x00432023,
6753 0x3242ffff, 0x3083ffff, 0x00431021, 0x02c2102a, 0x10400003, 0x00802821,
6754 0x97a9001e, 0x01322823, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000,
6755 0xa4c5000e, 0x8e020000, 0xacc20000, 0x8e020004, 0x8e63fff4, 0x00431021,
6756 0xacc20004, 0x8e63fff4, 0x96020008, 0x00641821, 0x0062102a, 0x14400006,
6757 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0x0a000571, 0xae62fff0,
6758 0xae63fff4, 0xacc00008, 0x3242ffff, 0x10560003, 0x31020004, 0x10400006,
6759 0x24020305, 0x31020080, 0x54400001, 0x34e70010, 0x34e70020, 0x24020905,
6760 0xa4c2000c, 0x8ee30000, 0x8ee20004, 0x14620007, 0x3c02b49a, 0x8ee20860,
6761 0x54400001, 0x34e70400, 0x3c024b65, 0x0a000588, 0x34427654, 0x344289ab,
6762 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005a2, 0x00c02021, 0x3242ffff,
6763 0x0056102b, 0x1440ff9b, 0x00000000, 0x8e620000, 0x8e63fffc, 0x0043102a,
6764 0x1440ff48, 0x00000000, 0x8fbf0044, 0x8fbe0040, 0x8fb7003c, 0x8fb60038,
6765 0x8fb50034, 0x8fb40030, 0x8fb3002c, 0x8fb20028, 0x8fb10024, 0x8fb00020,
6766 0x03e00008, 0x27bd0048, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f624450,
6767 0x8f634410, 0x0a0005b1, 0x00808021, 0x8f626820, 0x30422000, 0x10400003,
6768 0x00000000, 0x0e0001f0, 0x00002021, 0x8f624450, 0x8f634410, 0x3042ffff,
6769 0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002,
6770 0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800, 0x8c421b40, 0x3063000f,
6771 0x24420001, 0x3c010800, 0xac221b40, 0x2c620002, 0x1040fff7, 0x00000000,
6772 0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009, 0x00000000, 0x8f626820,
6773 0x30422000, 0x1040fff8, 0x00000000, 0x0e0001f0, 0x00002021, 0x0a0005c4,
6774 0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x00000000,
6775 0x00000000, 0x00000000, 0x27bdffe8, 0x3c1bc000, 0xafbf0014, 0xafb00010,
6776 0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804, 0x8f634000, 0x24020b50,
6777 0x3c010800, 0xac221b54, 0x24020b78, 0x3c010800, 0xac221b64, 0x34630002,
6778 0xaf634000, 0x0e000605, 0x00808021, 0x3c010800, 0xa0221b68, 0x304200ff,
6779 0x24030002, 0x14430005, 0x00000000, 0x3c020800, 0x8c421b54, 0x0a0005f8,
6780 0xac5000c0, 0x3c020800, 0x8c421b54, 0xac5000bc, 0x8f624434, 0x8f634438,
6781 0x8f644410, 0x3c010800, 0xac221b5c, 0x3c010800, 0xac231b6c, 0x3c010800,
6782 0xac241b58, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c040800,
6783 0x8c870000, 0x3c03aa55, 0x3463aa55, 0x3c06c003, 0xac830000, 0x8cc20000,
6784 0x14430007, 0x24050002, 0x3c0355aa, 0x346355aa, 0xac830000, 0x8cc20000,
6785 0x50430001, 0x24050001, 0x3c020800, 0xac470000, 0x03e00008, 0x00a01021,
6786 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c, 0x8f62680c, 0x1043fffe,
6787 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9, 0x00000000, 0x03e00008,
6788 0x27bd0008, 0x8f634450, 0x3c020800, 0x8c421b5c, 0x00031c02, 0x0043102b,
6789 0x14400008, 0x3c038000, 0x3c040800, 0x8c841b6c, 0x8f624450, 0x00021c02,
6790 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444, 0x00431024,
6791 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff, 0x3082ffff,
6792 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000, 0x0a000648, 0x2402ffff,
6793 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc, 0x00001021,
6794 0x03e00008, 0x00000000, 0x8f624450, 0x3c030800, 0x8c631b58, 0x0a000651,
6795 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b, 0x1440fffc, 0x00000000,
6796 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821, 0x3c040800, 0x24841af0,
6797 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00067c, 0xafa00014,
6798 0x0a000660, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x00000000,
6799 0x00000000, 0x00000000, 0x3c020800, 0x34423000, 0x3c030800, 0x34633000,
6800 0x3c040800, 0x348437ff, 0x3c010800, 0xac221b74, 0x24020040, 0x3c010800,
6801 0xac221b78, 0x3c010800, 0xac201b70, 0xac600000, 0x24630004, 0x0083102b,
6802 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000, 0x00804821, 0x8faa0010,
6803 0x3c020800, 0x8c421b70, 0x3c040800, 0x8c841b78, 0x8fab0014, 0x24430001,
6804 0x0044102b, 0x3c010800, 0xac231b70, 0x14400003, 0x00004021, 0x3c010800,
6805 0xac201b70, 0x3c020800, 0x8c421b70, 0x3c030800, 0x8c631b74, 0x91240000,
6806 0x00021140, 0x00431021, 0x00481021, 0x25080001, 0xa0440000, 0x29020008,
6807 0x1440fff4, 0x25290001, 0x3c020800, 0x8c421b70, 0x3c030800, 0x8c631b74,
6808 0x8f64680c, 0x00021140, 0x00431021, 0xac440008, 0xac45000c, 0xac460010,
6809 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c, 0x00000000, 0x00000000,
6810};
6811
6812static const u32 tg3TsoFwRodata[] = {
6813 0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
6814 0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x496e0000, 0x73746b6f,
6815 0x66662a2a, 0x00000000, 0x53774576, 0x656e7430, 0x00000000, 0x00000000,
6816 0x00000000, 0x00000000, 0x66617461, 0x6c457272, 0x00000000, 0x00000000,
6817 0x00000000,
6818};
6819
6820static const u32 tg3TsoFwData[] = {
6821 0x00000000, 0x73746b6f, 0x66666c64, 0x5f76312e, 0x362e3000, 0x00000000,
6822 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
6823 0x00000000,
6824};
6825
6826/* 5705 needs a special version of the TSO firmware. */ 6378/* 5705 needs a special version of the TSO firmware. */
6827#define TG3_TSO5_FW_RELEASE_MAJOR 0x1
6828#define TG3_TSO5_FW_RELASE_MINOR 0x2
6829#define TG3_TSO5_FW_RELEASE_FIX 0x0
6830#define TG3_TSO5_FW_START_ADDR 0x00010000
6831#define TG3_TSO5_FW_TEXT_ADDR 0x00010000
6832#define TG3_TSO5_FW_TEXT_LEN 0xe90
6833#define TG3_TSO5_FW_RODATA_ADDR 0x00010e90
6834#define TG3_TSO5_FW_RODATA_LEN 0x50
6835#define TG3_TSO5_FW_DATA_ADDR 0x00010f00
6836#define TG3_TSO5_FW_DATA_LEN 0x20
6837#define TG3_TSO5_FW_SBSS_ADDR 0x00010f20
6838#define TG3_TSO5_FW_SBSS_LEN 0x28
6839#define TG3_TSO5_FW_BSS_ADDR 0x00010f50
6840#define TG3_TSO5_FW_BSS_LEN 0x88
6841
6842static const u32 tg3Tso5FwText[(TG3_TSO5_FW_TEXT_LEN / 4) + 1] = {
6843 0x0c004003, 0x00000000, 0x00010f04, 0x00000000, 0x10000003, 0x00000000,
6844 0x0000000d, 0x0000000d, 0x3c1d0001, 0x37bde000, 0x03a0f021, 0x3c100001,
6845 0x26100000, 0x0c004010, 0x00000000, 0x0000000d, 0x27bdffe0, 0x3c04fefe,
6846 0xafbf0018, 0x0c0042e8, 0x34840002, 0x0c004364, 0x00000000, 0x3c030001,
6847 0x90630f34, 0x24020002, 0x3c040001, 0x24840e9c, 0x14620003, 0x24050001,
6848 0x3c040001, 0x24840e90, 0x24060002, 0x00003821, 0xafa00010, 0x0c004378,
6849 0xafa00014, 0x0c00402c, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
6850 0x00000000, 0x00000000, 0x27bdffe0, 0xafbf001c, 0xafb20018, 0xafb10014,
6851 0x0c0042d4, 0xafb00010, 0x3c128000, 0x24110001, 0x8f706810, 0x32020400,
6852 0x10400007, 0x00000000, 0x8f641008, 0x00921024, 0x14400003, 0x00000000,
6853 0x0c004064, 0x00000000, 0x3c020001, 0x90420f56, 0x10510003, 0x32020200,
6854 0x1040fff1, 0x00000000, 0x0c0041b4, 0x00000000, 0x08004034, 0x00000000,
6855 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
6856 0x27bdffe0, 0x3c040001, 0x24840eb0, 0x00002821, 0x00003021, 0x00003821,
6857 0xafbf0018, 0xafa00010, 0x0c004378, 0xafa00014, 0x0000d021, 0x24020130,
6858 0xaf625000, 0x3c010001, 0xa4200f50, 0x3c010001, 0xa0200f57, 0x8fbf0018,
6859 0x03e00008, 0x27bd0020, 0x00000000, 0x00000000, 0x3c030001, 0x24630f60,
6860 0x90620000, 0x27bdfff0, 0x14400003, 0x0080c021, 0x08004073, 0x00004821,
6861 0x3c022000, 0x03021024, 0x10400003, 0x24090002, 0x08004073, 0xa0600000,
6862 0x24090001, 0x00181040, 0x30431f80, 0x346f8008, 0x1520004b, 0x25eb0028,
6863 0x3c040001, 0x00832021, 0x8c848010, 0x3c050001, 0x24a50f7a, 0x00041402,
6864 0xa0a20000, 0x3c010001, 0xa0240f7b, 0x3c020001, 0x00431021, 0x94428014,
6865 0x3c010001, 0xa0220f7c, 0x3c0c0001, 0x01836021, 0x8d8c8018, 0x304200ff,
6866 0x24420008, 0x000220c3, 0x24020001, 0x3c010001, 0xa0220f60, 0x0124102b,
6867 0x1040000c, 0x00003821, 0x24a6000e, 0x01602821, 0x8ca20000, 0x8ca30004,
6868 0x24a50008, 0x24e70001, 0xacc20000, 0xacc30004, 0x00e4102b, 0x1440fff8,
6869 0x24c60008, 0x00003821, 0x3c080001, 0x25080f7b, 0x91060000, 0x3c020001,
6870 0x90420f7c, 0x2503000d, 0x00c32821, 0x00461023, 0x00021fc2, 0x00431021,
6871 0x00021043, 0x1840000c, 0x00002021, 0x91020001, 0x00461023, 0x00021fc2,
6872 0x00431021, 0x00021843, 0x94a20000, 0x24e70001, 0x00822021, 0x00e3102a,
6873 0x1440fffb, 0x24a50002, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
6874 0x00822021, 0x3c02ffff, 0x01821024, 0x3083ffff, 0x00431025, 0x3c010001,
6875 0x080040fa, 0xac220f80, 0x3c050001, 0x24a50f7c, 0x90a20000, 0x3c0c0001,
6876 0x01836021, 0x8d8c8018, 0x000220c2, 0x1080000e, 0x00003821, 0x01603021,
6877 0x24a5000c, 0x8ca20000, 0x8ca30004, 0x24a50008, 0x24e70001, 0xacc20000,
6878 0xacc30004, 0x00e4102b, 0x1440fff8, 0x24c60008, 0x3c050001, 0x24a50f7c,
6879 0x90a20000, 0x30430007, 0x24020004, 0x10620011, 0x28620005, 0x10400005,
6880 0x24020002, 0x10620008, 0x000710c0, 0x080040fa, 0x00000000, 0x24020006,
6881 0x1062000e, 0x000710c0, 0x080040fa, 0x00000000, 0x00a21821, 0x9463000c,
6882 0x004b1021, 0x080040fa, 0xa4430000, 0x000710c0, 0x00a21821, 0x8c63000c,
6883 0x004b1021, 0x080040fa, 0xac430000, 0x00a21821, 0x8c63000c, 0x004b2021,
6884 0x00a21021, 0xac830000, 0x94420010, 0xa4820004, 0x95e70006, 0x3c020001,
6885 0x90420f7c, 0x3c030001, 0x90630f7a, 0x00e2c823, 0x3c020001, 0x90420f7b,
6886 0x24630028, 0x01e34021, 0x24420028, 0x15200012, 0x01e23021, 0x94c2000c,
6887 0x3c010001, 0xa4220f78, 0x94c20004, 0x94c30006, 0x3c010001, 0xa4200f76,
6888 0x3c010001, 0xa4200f72, 0x00021400, 0x00431025, 0x3c010001, 0xac220f6c,
6889 0x95020004, 0x3c010001, 0x08004124, 0xa4220f70, 0x3c020001, 0x94420f70,
6890 0x3c030001, 0x94630f72, 0x00431021, 0xa5020004, 0x3c020001, 0x94420f6c,
6891 0xa4c20004, 0x3c020001, 0x8c420f6c, 0xa4c20006, 0x3c040001, 0x94840f72,
6892 0x3c020001, 0x94420f70, 0x3c0a0001, 0x954a0f76, 0x00441821, 0x3063ffff,
6893 0x0062182a, 0x24020002, 0x1122000b, 0x00832023, 0x3c030001, 0x94630f78,
6894 0x30620009, 0x10400006, 0x3062fff6, 0xa4c2000c, 0x3c020001, 0x94420f78,
6895 0x30420009, 0x01425023, 0x24020001, 0x1122001b, 0x29220002, 0x50400005,
6896 0x24020002, 0x11200007, 0x31a2ffff, 0x08004197, 0x00000000, 0x1122001d,
6897 0x24020016, 0x08004197, 0x31a2ffff, 0x3c0e0001, 0x95ce0f80, 0x10800005,
6898 0x01806821, 0x01c42021, 0x00041c02, 0x3082ffff, 0x00627021, 0x000e1027,
6899 0xa502000a, 0x3c030001, 0x90630f7b, 0x31a2ffff, 0x00e21021, 0x0800418d,
6900 0x00432023, 0x3c020001, 0x94420f80, 0x00442021, 0x00041c02, 0x3082ffff,
6901 0x00622021, 0x00807021, 0x00041027, 0x08004185, 0xa502000a, 0x3c050001,
6902 0x24a50f7a, 0x90a30000, 0x14620002, 0x24e2fff2, 0xa5e20034, 0x90a20000,
6903 0x00e21023, 0xa5020002, 0x3c030001, 0x94630f80, 0x3c020001, 0x94420f5a,
6904 0x30e5ffff, 0x00641821, 0x00451023, 0x00622023, 0x00041c02, 0x3082ffff,
6905 0x00622021, 0x00041027, 0xa502000a, 0x3c030001, 0x90630f7c, 0x24620001,
6906 0x14a20005, 0x00807021, 0x01631021, 0x90420000, 0x08004185, 0x00026200,
6907 0x24620002, 0x14a20003, 0x306200fe, 0x004b1021, 0x944c0000, 0x3c020001,
6908 0x94420f82, 0x3183ffff, 0x3c040001, 0x90840f7b, 0x00431021, 0x00e21021,
6909 0x00442023, 0x008a2021, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
6910 0x00822021, 0x00806821, 0x00041027, 0xa4c20010, 0x31a2ffff, 0x000e1c00,
6911 0x00431025, 0x3c040001, 0x24840f72, 0xade20010, 0x94820000, 0x3c050001,
6912 0x94a50f76, 0x3c030001, 0x8c630f6c, 0x24420001, 0x00b92821, 0xa4820000,
6913 0x3322ffff, 0x00622021, 0x0083182b, 0x3c010001, 0xa4250f76, 0x10600003,
6914 0x24a2ffff, 0x3c010001, 0xa4220f76, 0x3c024000, 0x03021025, 0x3c010001,
6915 0xac240f6c, 0xaf621008, 0x03e00008, 0x27bd0010, 0x3c030001, 0x90630f56,
6916 0x27bdffe8, 0x24020001, 0xafbf0014, 0x10620026, 0xafb00010, 0x8f620cf4,
6917 0x2442ffff, 0x3042007f, 0x00021100, 0x8c434000, 0x3c010001, 0xac230f64,
6918 0x8c434008, 0x24444000, 0x8c5c4004, 0x30620040, 0x14400002, 0x24020088,
6919 0x24020008, 0x3c010001, 0xa4220f68, 0x30620004, 0x10400005, 0x24020001,
6920 0x3c010001, 0xa0220f57, 0x080041d5, 0x00031402, 0x3c010001, 0xa0200f57,
6921 0x00031402, 0x3c010001, 0xa4220f54, 0x9483000c, 0x24020001, 0x3c010001,
6922 0xa4200f50, 0x3c010001, 0xa0220f56, 0x3c010001, 0xa4230f62, 0x24020001,
6923 0x1342001e, 0x00000000, 0x13400005, 0x24020003, 0x13420067, 0x00000000,
6924 0x080042cf, 0x00000000, 0x3c020001, 0x94420f62, 0x241a0001, 0x3c010001,
6925 0xa4200f5e, 0x3c010001, 0xa4200f52, 0x304407ff, 0x00021bc2, 0x00031823,
6926 0x3063003e, 0x34630036, 0x00021242, 0x3042003c, 0x00621821, 0x3c010001,
6927 0xa4240f58, 0x00832021, 0x24630030, 0x3c010001, 0xa4240f5a, 0x3c010001,
6928 0xa4230f5c, 0x3c060001, 0x24c60f52, 0x94c50000, 0x94c30002, 0x3c040001,
6929 0x94840f5a, 0x00651021, 0x0044102a, 0x10400013, 0x3c108000, 0x00a31021,
6930 0xa4c20000, 0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f56, 0x8f641008,
6931 0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4,
6932 0x00501024, 0x104000b7, 0x00000000, 0x0800420f, 0x00000000, 0x3c030001,
6933 0x94630f50, 0x00851023, 0xa4c40000, 0x00621821, 0x3042ffff, 0x3c010001,
6934 0xa4230f50, 0xaf620ce8, 0x3c020001, 0x94420f68, 0x34420024, 0xaf620cec,
6935 0x94c30002, 0x3c020001, 0x94420f50, 0x14620012, 0x3c028000, 0x3c108000,
6936 0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f56, 0x8f641008, 0x00901024,
6937 0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024,
6938 0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003, 0xaf620cf4, 0x3c108000,
6939 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000,
6940 0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003,
6941 0x3c070001, 0x24e70f50, 0x94e20000, 0x03821021, 0xaf620ce0, 0x3c020001,
6942 0x8c420f64, 0xaf620ce4, 0x3c050001, 0x94a50f54, 0x94e30000, 0x3c040001,
6943 0x94840f58, 0x3c020001, 0x94420f5e, 0x00a32823, 0x00822023, 0x30a6ffff,
6944 0x3083ffff, 0x00c3102b, 0x14400043, 0x00000000, 0x3c020001, 0x94420f5c,
6945 0x00021400, 0x00621025, 0xaf620ce8, 0x94e20000, 0x3c030001, 0x94630f54,
6946 0x00441021, 0xa4e20000, 0x3042ffff, 0x14430021, 0x3c020008, 0x3c020001,
6947 0x90420f57, 0x10400006, 0x3c03000c, 0x3c020001, 0x94420f68, 0x34630624,
6948 0x0800427c, 0x0000d021, 0x3c020001, 0x94420f68, 0x3c030008, 0x34630624,
6949 0x00431025, 0xaf620cec, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
6950 0xa0200f56, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
6951 0x00000000, 0x8f620cf4, 0x00501024, 0x10400015, 0x00000000, 0x08004283,
6952 0x00000000, 0x3c030001, 0x94630f68, 0x34420624, 0x3c108000, 0x00621825,
6953 0x3c028000, 0xaf630cec, 0xaf620cf4, 0x8f641008, 0x00901024, 0x14400003,
6954 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7,
6955 0x00000000, 0x3c010001, 0x080042cf, 0xa4200f5e, 0x3c020001, 0x94420f5c,
6956 0x00021400, 0x00c21025, 0xaf620ce8, 0x3c020001, 0x90420f57, 0x10400009,
6957 0x3c03000c, 0x3c020001, 0x94420f68, 0x34630624, 0x0000d021, 0x00431025,
6958 0xaf620cec, 0x080042c1, 0x3c108000, 0x3c020001, 0x94420f68, 0x3c030008,
6959 0x34630604, 0x00431025, 0xaf620cec, 0x3c020001, 0x94420f5e, 0x00451021,
6960 0x3c010001, 0xa4220f5e, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
6961 0xa0200f56, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
6962 0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x8fbf0014,
6963 0x8fb00010, 0x03e00008, 0x27bd0018, 0x00000000, 0x27bdffe0, 0x3c040001,
6964 0x24840ec0, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
6965 0x0c004378, 0xafa00014, 0x0000d021, 0x24020130, 0xaf625000, 0x3c010001,
6966 0xa4200f50, 0x3c010001, 0xa0200f57, 0x8fbf0018, 0x03e00008, 0x27bd0020,
6967 0x27bdffe8, 0x3c1bc000, 0xafbf0014, 0xafb00010, 0xaf60680c, 0x8f626804,
6968 0x34420082, 0xaf626804, 0x8f634000, 0x24020b50, 0x3c010001, 0xac220f20,
6969 0x24020b78, 0x3c010001, 0xac220f30, 0x34630002, 0xaf634000, 0x0c004315,
6970 0x00808021, 0x3c010001, 0xa0220f34, 0x304200ff, 0x24030002, 0x14430005,
6971 0x00000000, 0x3c020001, 0x8c420f20, 0x08004308, 0xac5000c0, 0x3c020001,
6972 0x8c420f20, 0xac5000bc, 0x8f624434, 0x8f634438, 0x8f644410, 0x3c010001,
6973 0xac220f28, 0x3c010001, 0xac230f38, 0x3c010001, 0xac240f24, 0x8fbf0014,
6974 0x8fb00010, 0x03e00008, 0x27bd0018, 0x03e00008, 0x24020001, 0x27bdfff8,
6975 0x18800009, 0x00002821, 0x8f63680c, 0x8f62680c, 0x1043fffe, 0x00000000,
6976 0x24a50001, 0x00a4102a, 0x1440fff9, 0x00000000, 0x03e00008, 0x27bd0008,
6977 0x8f634450, 0x3c020001, 0x8c420f28, 0x00031c02, 0x0043102b, 0x14400008,
6978 0x3c038000, 0x3c040001, 0x8c840f38, 0x8f624450, 0x00021c02, 0x0083102b,
6979 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444, 0x00431024, 0x1440fffd,
6980 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff, 0x3082ffff, 0x2442e000,
6981 0x2c422001, 0x14400003, 0x3c024000, 0x08004347, 0x2402ffff, 0x00822025,
6982 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc, 0x00001021, 0x03e00008,
6983 0x00000000, 0x8f624450, 0x3c030001, 0x8c630f24, 0x08004350, 0x3042ffff,
6984 0x8f624450, 0x3042ffff, 0x0043102b, 0x1440fffc, 0x00000000, 0x03e00008,
6985 0x00000000, 0x27bdffe0, 0x00802821, 0x3c040001, 0x24840ed0, 0x00003021,
6986 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004378, 0xafa00014, 0x0800435f,
6987 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x3c020001, 0x3442d600,
6988 0x3c030001, 0x3463d600, 0x3c040001, 0x3484ddff, 0x3c010001, 0xac220f40,
6989 0x24020040, 0x3c010001, 0xac220f44, 0x3c010001, 0xac200f3c, 0xac600000,
6990 0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
6991 0x00804821, 0x8faa0010, 0x3c020001, 0x8c420f3c, 0x3c040001, 0x8c840f44,
6992 0x8fab0014, 0x24430001, 0x0044102b, 0x3c010001, 0xac230f3c, 0x14400003,
6993 0x00004021, 0x3c010001, 0xac200f3c, 0x3c020001, 0x8c420f3c, 0x3c030001,
6994 0x8c630f40, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
6995 0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020001, 0x8c420f3c,
6996 0x3c030001, 0x8c630f40, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
6997 0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
6998 0x00000000, 0x00000000, 0x00000000,
6999};
7000
7001static const u32 tg3Tso5FwRodata[(TG3_TSO5_FW_RODATA_LEN / 4) + 1] = {
7002 0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
7003 0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000,
7004 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
7005 0x00000000, 0x00000000, 0x00000000,
7006};
7007
7008static const u32 tg3Tso5FwData[(TG3_TSO5_FW_DATA_LEN / 4) + 1] = {
7009 0x00000000, 0x73746b6f, 0x66666c64, 0x5f76312e, 0x322e3000, 0x00000000,
7010 0x00000000, 0x00000000, 0x00000000,
7011};
7012 6379
7013/* tp->lock is held. */ 6380/* tp->lock is held. */
7014static int tg3_load_tso_firmware(struct tg3 *tp) 6381static int tg3_load_tso_firmware(struct tg3 *tp)
7015{ 6382{
7016 struct fw_info info; 6383 struct fw_info info;
6384 const __be32 *fw_data;
7017 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size; 6385 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
7018 int err, i; 6386 int err, i;
7019 6387
7020 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 6388 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
7021 return 0; 6389 return 0;
7022 6390
6391 fw_data = (void *)tp->fw->data;
6392
6393 /* Firmware blob starts with version numbers, followed by
6394 start address and length. We are setting complete length.
6395 length = end_address_of_bss - start_address_of_text.
6396 Remainder is the blob to be loaded contiguously
6397 from start address. */
6398
6399 info.fw_base = be32_to_cpu(fw_data[1]);
6400 cpu_scratch_size = tp->fw_len;
6401 info.fw_len = tp->fw->size - 12;
6402 info.fw_data = &fw_data[3];
6403
7023 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) { 6404 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
7024 info.text_base = TG3_TSO5_FW_TEXT_ADDR;
7025 info.text_len = TG3_TSO5_FW_TEXT_LEN;
7026 info.text_data = &tg3Tso5FwText[0];
7027 info.rodata_base = TG3_TSO5_FW_RODATA_ADDR;
7028 info.rodata_len = TG3_TSO5_FW_RODATA_LEN;
7029 info.rodata_data = &tg3Tso5FwRodata[0];
7030 info.data_base = TG3_TSO5_FW_DATA_ADDR;
7031 info.data_len = TG3_TSO5_FW_DATA_LEN;
7032 info.data_data = &tg3Tso5FwData[0];
7033 cpu_base = RX_CPU_BASE; 6405 cpu_base = RX_CPU_BASE;
7034 cpu_scratch_base = NIC_SRAM_MBUF_POOL_BASE5705; 6406 cpu_scratch_base = NIC_SRAM_MBUF_POOL_BASE5705;
7035 cpu_scratch_size = (info.text_len +
7036 info.rodata_len +
7037 info.data_len +
7038 TG3_TSO5_FW_SBSS_LEN +
7039 TG3_TSO5_FW_BSS_LEN);
7040 } else { 6407 } else {
7041 info.text_base = TG3_TSO_FW_TEXT_ADDR;
7042 info.text_len = TG3_TSO_FW_TEXT_LEN;
7043 info.text_data = &tg3TsoFwText[0];
7044 info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
7045 info.rodata_len = TG3_TSO_FW_RODATA_LEN;
7046 info.rodata_data = &tg3TsoFwRodata[0];
7047 info.data_base = TG3_TSO_FW_DATA_ADDR;
7048 info.data_len = TG3_TSO_FW_DATA_LEN;
7049 info.data_data = &tg3TsoFwData[0];
7050 cpu_base = TX_CPU_BASE; 6408 cpu_base = TX_CPU_BASE;
7051 cpu_scratch_base = TX_CPU_SCRATCH_BASE; 6409 cpu_scratch_base = TX_CPU_SCRATCH_BASE;
7052 cpu_scratch_size = TX_CPU_SCRATCH_SIZE; 6410 cpu_scratch_size = TX_CPU_SCRATCH_SIZE;
@@ -7060,21 +6418,21 @@ static int tg3_load_tso_firmware(struct tg3 *tp)
7060 6418
7061 /* Now startup the cpu. */ 6419 /* Now startup the cpu. */
7062 tw32(cpu_base + CPU_STATE, 0xffffffff); 6420 tw32(cpu_base + CPU_STATE, 0xffffffff);
7063 tw32_f(cpu_base + CPU_PC, info.text_base); 6421 tw32_f(cpu_base + CPU_PC, info.fw_base);
7064 6422
7065 for (i = 0; i < 5; i++) { 6423 for (i = 0; i < 5; i++) {
7066 if (tr32(cpu_base + CPU_PC) == info.text_base) 6424 if (tr32(cpu_base + CPU_PC) == info.fw_base)
7067 break; 6425 break;
7068 tw32(cpu_base + CPU_STATE, 0xffffffff); 6426 tw32(cpu_base + CPU_STATE, 0xffffffff);
7069 tw32(cpu_base + CPU_MODE, CPU_MODE_HALT); 6427 tw32(cpu_base + CPU_MODE, CPU_MODE_HALT);
7070 tw32_f(cpu_base + CPU_PC, info.text_base); 6428 tw32_f(cpu_base + CPU_PC, info.fw_base);
7071 udelay(1000); 6429 udelay(1000);
7072 } 6430 }
7073 if (i >= 5) { 6431 if (i >= 5) {
7074 printk(KERN_ERR PFX "tg3_load_tso_firmware fails for %s " 6432 printk(KERN_ERR PFX "tg3_load_tso_firmware fails for %s "
7075 "to set CPU PC, is %08x should be %08x\n", 6433 "to set CPU PC, is %08x should be %08x\n",
7076 tp->dev->name, tr32(cpu_base + CPU_PC), 6434 tp->dev->name, tr32(cpu_base + CPU_PC),
7077 info.text_base); 6435 info.fw_base);
7078 return -ENODEV; 6436 return -ENODEV;
7079 } 6437 }
7080 tw32(cpu_base + CPU_STATE, 0xffffffff); 6438 tw32(cpu_base + CPU_STATE, 0xffffffff);
@@ -7299,11 +6657,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7299 else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) { 6657 else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
7300 int fw_len; 6658 int fw_len;
7301 6659
7302 fw_len = (TG3_TSO5_FW_TEXT_LEN + 6660 fw_len = tp->fw_len;
7303 TG3_TSO5_FW_RODATA_LEN +
7304 TG3_TSO5_FW_DATA_LEN +
7305 TG3_TSO5_FW_SBSS_LEN +
7306 TG3_TSO5_FW_BSS_LEN);
7307 fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1); 6661 fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1);
7308 tw32(BUFMGR_MB_POOL_ADDR, 6662 tw32(BUFMGR_MB_POOL_ADDR,
7309 NIC_SRAM_MBUF_POOL_BASE5705 + fw_len); 6663 NIC_SRAM_MBUF_POOL_BASE5705 + fw_len);
@@ -13580,6 +12934,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13580 struct net_device *dev; 12934 struct net_device *dev;
13581 struct tg3 *tp; 12935 struct tg3 *tp;
13582 int err, pm_cap; 12936 int err, pm_cap;
12937 const char *fw_name = NULL;
13583 char str[40]; 12938 char str[40];
13584 u64 dma_mask, persist_dma_mask; 12939 u64 dma_mask, persist_dma_mask;
13585 12940
@@ -13735,6 +13090,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13735 13090
13736 tg3_init_bufmgr_config(tp); 13091 tg3_init_bufmgr_config(tp);
13737 13092
13093 if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0)
13094 fw_name = FIRMWARE_TG3;
13095
13738 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { 13096 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
13739 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE; 13097 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
13740 } 13098 }
@@ -13747,6 +13105,37 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13747 } else { 13105 } else {
13748 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE | TG3_FLG2_TSO_BUG; 13106 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE | TG3_FLG2_TSO_BUG;
13749 } 13107 }
13108 if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
13109 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
13110 fw_name = FIRMWARE_TG3TSO5;
13111 else
13112 fw_name = FIRMWARE_TG3TSO;
13113 }
13114
13115 if (fw_name) {
13116 const __be32 *fw_data;
13117
13118 err = request_firmware(&tp->fw, fw_name, &tp->pdev->dev);
13119 if (err) {
13120 printk(KERN_ERR "tg3: Failed to load firmware \"%s\"\n",
13121 fw_name);
13122 goto err_out_iounmap;
13123 }
13124
13125 fw_data = (void *)tp->fw->data;
13126
13127 /* Firmware blob starts with version numbers, followed by
13128 start address and _full_ length including BSS sections
13129 (which must be longer than the actual data, of course */
13130
13131 tp->fw_len = be32_to_cpu(fw_data[2]); /* includes bss */
13132 if (tp->fw_len < (tp->fw->size - 12)) {
13133 printk(KERN_ERR "tg3: bogus length %d in \"%s\"\n",
13134 tp->fw_len, fw_name);
13135 err = -EINVAL;
13136 goto err_out_fw;
13137 }
13138 }
13750 13139
13751 /* TSO is on by default on chips that support hardware TSO. 13140 /* TSO is on by default on chips that support hardware TSO.
13752 * Firmware TSO on older chips gives lower performance, so it 13141 * Firmware TSO on older chips gives lower performance, so it
@@ -13778,7 +13167,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13778 if (err) { 13167 if (err) {
13779 printk(KERN_ERR PFX "Could not obtain valid ethernet address, " 13168 printk(KERN_ERR PFX "Could not obtain valid ethernet address, "
13780 "aborting.\n"); 13169 "aborting.\n");
13781 goto err_out_iounmap; 13170 goto err_out_fw;
13782 } 13171 }
13783 13172
13784 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { 13173 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
@@ -13787,7 +13176,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13787 printk(KERN_ERR PFX "Cannot map APE registers, " 13176 printk(KERN_ERR PFX "Cannot map APE registers, "
13788 "aborting.\n"); 13177 "aborting.\n");
13789 err = -ENOMEM; 13178 err = -ENOMEM;
13790 goto err_out_iounmap; 13179 goto err_out_fw;
13791 } 13180 }
13792 13181
13793 tg3_ape_lock_init(tp); 13182 tg3_ape_lock_init(tp);
@@ -13867,6 +13256,10 @@ err_out_apeunmap:
13867 tp->aperegs = NULL; 13256 tp->aperegs = NULL;
13868 } 13257 }
13869 13258
13259err_out_fw:
13260 if (tp->fw)
13261 release_firmware(tp->fw);
13262
13870err_out_iounmap: 13263err_out_iounmap:
13871 if (tp->regs) { 13264 if (tp->regs) {
13872 iounmap(tp->regs); 13265 iounmap(tp->regs);
@@ -13892,6 +13285,9 @@ static void __devexit tg3_remove_one(struct pci_dev *pdev)
13892 if (dev) { 13285 if (dev) {
13893 struct tg3 *tp = netdev_priv(dev); 13286 struct tg3 *tp = netdev_priv(dev);
13894 13287
13288 if (tp->fw)
13289 release_firmware(tp->fw);
13290
13895 flush_scheduled_work(); 13291 flush_scheduled_work();
13896 13292
13897 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) { 13293 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) {
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 8936edfb0438..ae5da603c6af 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2762,6 +2762,10 @@ struct tg3 {
2762#define SST_25VF0X0_PAGE_SIZE 4098 2762#define SST_25VF0X0_PAGE_SIZE 4098
2763 2763
2764 struct ethtool_coalesce coal; 2764 struct ethtool_coalesce coal;
2765
2766 /* firmware info */
2767 const struct firmware *fw;
2768 u32 fw_len; /* includes BSS */
2765}; 2769};
2766 2770
2767#endif /* !(_T3_H) */ 2771#endif /* !(_T3_H) */
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 69f9a0ec764d..d7b81e4fdd56 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -213,7 +213,7 @@ static int check_filter(struct tap_filter *filter, const struct sk_buff *skb)
213 213
214/* Network device part of the driver */ 214/* Network device part of the driver */
215 215
216static unsigned int tun_net_id; 216static int tun_net_id;
217struct tun_net { 217struct tun_net {
218 struct list_head dev_list; 218 struct list_head dev_list;
219}; 219};
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index ddc4c59f02dc..b7e4cee24269 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -29,9 +29,6 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode)
29 29
30 if (inode) { 30 if (inode) {
31 inode->i_mode = mode; 31 inode->i_mode = mode;
32 inode->i_uid = 0;
33 inode->i_gid = 0;
34 inode->i_blocks = 0;
35 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 32 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
36 } 33 }
37 return inode; 34 return inode;
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 123092d8a984..165a81843357 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -102,9 +102,13 @@ config RTC_INTF_DEV_UIE_EMUL
102 depends on RTC_INTF_DEV 102 depends on RTC_INTF_DEV
103 help 103 help
104 Provides an emulation for RTC_UIE if the underlying rtc chip 104 Provides an emulation for RTC_UIE if the underlying rtc chip
105 driver does not expose RTC_UIE ioctls. Those requests generate 105 driver does not expose RTC_UIE ioctls. Those requests generate
106 once-per-second update interrupts, used for synchronization. 106 once-per-second update interrupts, used for synchronization.
107 107
108 The emulation code will read the time from the hardware
109 clock several times per second, please enable this option
110 only if you know that you really need it.
111
108config RTC_DRV_TEST 112config RTC_DRV_TEST
109 tristate "Test driver/device" 113 tristate "Test driver/device"
110 help 114 help
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index a04c1b6b1575..fd2c652504ff 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -307,6 +307,60 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
307} 307}
308EXPORT_SYMBOL_GPL(rtc_set_alarm); 308EXPORT_SYMBOL_GPL(rtc_set_alarm);
309 309
310int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
311{
312 int err = mutex_lock_interruptible(&rtc->ops_lock);
313 if (err)
314 return err;
315
316 if (!rtc->ops)
317 err = -ENODEV;
318 else if (!rtc->ops->alarm_irq_enable)
319 err = -EINVAL;
320 else
321 err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled);
322
323 mutex_unlock(&rtc->ops_lock);
324 return err;
325}
326EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable);
327
328int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
329{
330 int err = mutex_lock_interruptible(&rtc->ops_lock);
331 if (err)
332 return err;
333
334#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
335 if (enabled == 0 && rtc->uie_irq_active) {
336 mutex_unlock(&rtc->ops_lock);
337 return rtc_dev_update_irq_enable_emul(rtc, enabled);
338 }
339#endif
340
341 if (!rtc->ops)
342 err = -ENODEV;
343 else if (!rtc->ops->update_irq_enable)
344 err = -EINVAL;
345 else
346 err = rtc->ops->update_irq_enable(rtc->dev.parent, enabled);
347
348 mutex_unlock(&rtc->ops_lock);
349
350#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
351 /*
352 * Enable emulation if the driver did not provide
353 * the update_irq_enable function pointer or if returned
354 * -EINVAL to signal that it has been configured without
355 * interrupts or that are not available at the moment.
356 */
357 if (err == -EINVAL)
358 err = rtc_dev_update_irq_enable_emul(rtc, enabled);
359#endif
360 return err;
361}
362EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
363
310/** 364/**
311 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs 365 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
312 * @rtc: the rtc device 366 * @rtc: the rtc device
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index ecdea44ae4e5..45152f4952d6 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -92,10 +92,10 @@ static void rtc_uie_timer(unsigned long data)
92 spin_unlock_irqrestore(&rtc->irq_lock, flags); 92 spin_unlock_irqrestore(&rtc->irq_lock, flags);
93} 93}
94 94
95static void clear_uie(struct rtc_device *rtc) 95static int clear_uie(struct rtc_device *rtc)
96{ 96{
97 spin_lock_irq(&rtc->irq_lock); 97 spin_lock_irq(&rtc->irq_lock);
98 if (rtc->irq_active) { 98 if (rtc->uie_irq_active) {
99 rtc->stop_uie_polling = 1; 99 rtc->stop_uie_polling = 1;
100 if (rtc->uie_timer_active) { 100 if (rtc->uie_timer_active) {
101 spin_unlock_irq(&rtc->irq_lock); 101 spin_unlock_irq(&rtc->irq_lock);
@@ -108,9 +108,10 @@ static void clear_uie(struct rtc_device *rtc)
108 flush_scheduled_work(); 108 flush_scheduled_work();
109 spin_lock_irq(&rtc->irq_lock); 109 spin_lock_irq(&rtc->irq_lock);
110 } 110 }
111 rtc->irq_active = 0; 111 rtc->uie_irq_active = 0;
112 } 112 }
113 spin_unlock_irq(&rtc->irq_lock); 113 spin_unlock_irq(&rtc->irq_lock);
114 return 0;
114} 115}
115 116
116static int set_uie(struct rtc_device *rtc) 117static int set_uie(struct rtc_device *rtc)
@@ -122,8 +123,8 @@ static int set_uie(struct rtc_device *rtc)
122 if (err) 123 if (err)
123 return err; 124 return err;
124 spin_lock_irq(&rtc->irq_lock); 125 spin_lock_irq(&rtc->irq_lock);
125 if (!rtc->irq_active) { 126 if (!rtc->uie_irq_active) {
126 rtc->irq_active = 1; 127 rtc->uie_irq_active = 1;
127 rtc->stop_uie_polling = 0; 128 rtc->stop_uie_polling = 0;
128 rtc->oldsecs = tm.tm_sec; 129 rtc->oldsecs = tm.tm_sec;
129 rtc->uie_task_active = 1; 130 rtc->uie_task_active = 1;
@@ -134,6 +135,16 @@ static int set_uie(struct rtc_device *rtc)
134 spin_unlock_irq(&rtc->irq_lock); 135 spin_unlock_irq(&rtc->irq_lock);
135 return 0; 136 return 0;
136} 137}
138
139int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc, unsigned int enabled)
140{
141 if (enabled)
142 return set_uie(rtc);
143 else
144 return clear_uie(rtc);
145}
146EXPORT_SYMBOL(rtc_dev_update_irq_enable_emul);
147
137#endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */ 148#endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */
138 149
139static ssize_t 150static ssize_t
@@ -357,6 +368,22 @@ static long rtc_dev_ioctl(struct file *file,
357 err = rtc_irq_set_state(rtc, NULL, 0); 368 err = rtc_irq_set_state(rtc, NULL, 0);
358 break; 369 break;
359 370
371 case RTC_AIE_ON:
372 mutex_unlock(&rtc->ops_lock);
373 return rtc_alarm_irq_enable(rtc, 1);
374
375 case RTC_AIE_OFF:
376 mutex_unlock(&rtc->ops_lock);
377 return rtc_alarm_irq_enable(rtc, 0);
378
379 case RTC_UIE_ON:
380 mutex_unlock(&rtc->ops_lock);
381 return rtc_update_irq_enable(rtc, 1);
382
383 case RTC_UIE_OFF:
384 mutex_unlock(&rtc->ops_lock);
385 return rtc_update_irq_enable(rtc, 0);
386
360 case RTC_IRQP_SET: 387 case RTC_IRQP_SET:
361 err = rtc_irq_set_freq(rtc, NULL, arg); 388 err = rtc_irq_set_freq(rtc, NULL, arg);
362 break; 389 break;
@@ -401,17 +428,6 @@ static long rtc_dev_ioctl(struct file *file,
401 err = -EFAULT; 428 err = -EFAULT;
402 return err; 429 return err;
403 430
404#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
405 case RTC_UIE_OFF:
406 mutex_unlock(&rtc->ops_lock);
407 clear_uie(rtc);
408 return 0;
409
410 case RTC_UIE_ON:
411 mutex_unlock(&rtc->ops_lock);
412 err = set_uie(rtc);
413 return err;
414#endif
415 default: 431 default:
416 err = -ENOTTY; 432 err = -ENOTTY;
417 break; 433 break;
@@ -440,7 +456,10 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
440 * Leave the alarm alone; it may be set to trigger a system wakeup 456 * Leave the alarm alone; it may be set to trigger a system wakeup
441 * later, or be used by kernel code, and is a one-shot event anyway. 457 * later, or be used by kernel code, and is a one-shot event anyway.
442 */ 458 */
459
460 /* Keep ioctl until all drivers are converted */
443 rtc_dev_ioctl(file, RTC_UIE_OFF, 0); 461 rtc_dev_ioctl(file, RTC_UIE_OFF, 0);
462 rtc_update_irq_enable(rtc, 0);
444 rtc_irq_set_state(rtc, NULL, 0); 463 rtc_irq_set_state(rtc, NULL, 0);
445 464
446 if (rtc->ops->release) 465 if (rtc->ops->release)
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
index d5ccce1643e4..e0c45574b0c8 100644
--- a/drivers/s390/net/qeth_core.h
+++ b/drivers/s390/net/qeth_core.h
@@ -643,7 +643,6 @@ struct qeth_card_options {
643 int macaddr_mode; 643 int macaddr_mode;
644 int fake_broadcast; 644 int fake_broadcast;
645 int add_hhlen; 645 int add_hhlen;
646 int fake_ll;
647 int layer2; 646 int layer2;
648 enum qeth_large_send_types large_send; 647 enum qeth_large_send_types large_send;
649 int performance_stats; 648 int performance_stats;
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index e783644a2105..6811dd529f48 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -287,8 +287,15 @@ int qeth_set_large_send(struct qeth_card *card,
287 card->options.large_send = type; 287 card->options.large_send = type;
288 switch (card->options.large_send) { 288 switch (card->options.large_send) {
289 case QETH_LARGE_SEND_EDDP: 289 case QETH_LARGE_SEND_EDDP:
290 card->dev->features |= NETIF_F_TSO | NETIF_F_SG | 290 if (card->info.type != QETH_CARD_TYPE_IQD) {
291 card->dev->features |= NETIF_F_TSO | NETIF_F_SG |
291 NETIF_F_HW_CSUM; 292 NETIF_F_HW_CSUM;
293 } else {
294 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG |
295 NETIF_F_HW_CSUM);
296 card->options.large_send = QETH_LARGE_SEND_NO;
297 rc = -EOPNOTSUPP;
298 }
292 break; 299 break;
293 case QETH_LARGE_SEND_TSO: 300 case QETH_LARGE_SEND_TSO:
294 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) { 301 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) {
@@ -572,6 +579,10 @@ static void qeth_send_control_data_cb(struct qeth_channel *channel,
572 card = CARD_FROM_CDEV(channel->ccwdev); 579 card = CARD_FROM_CDEV(channel->ccwdev);
573 if (qeth_check_idx_response(iob->data)) { 580 if (qeth_check_idx_response(iob->data)) {
574 qeth_clear_ipacmd_list(card); 581 qeth_clear_ipacmd_list(card);
582 if (((iob->data[2] & 0xc0) == 0xc0) && iob->data[4] == 0xf6)
583 dev_err(&card->gdev->dev,
584 "The qeth device is not configured "
585 "for the OSI layer required by z/VM\n");
575 qeth_schedule_recovery(card); 586 qeth_schedule_recovery(card);
576 goto out; 587 goto out;
577 } 588 }
@@ -1072,7 +1083,6 @@ static void qeth_set_intial_options(struct qeth_card *card)
1072 card->options.macaddr_mode = QETH_TR_MACADDR_NONCANONICAL; 1083 card->options.macaddr_mode = QETH_TR_MACADDR_NONCANONICAL;
1073 card->options.fake_broadcast = 0; 1084 card->options.fake_broadcast = 0;
1074 card->options.add_hhlen = DEFAULT_ADD_HHLEN; 1085 card->options.add_hhlen = DEFAULT_ADD_HHLEN;
1075 card->options.fake_ll = 0;
1076 card->options.performance_stats = 0; 1086 card->options.performance_stats = 0;
1077 card->options.rx_sg_cb = QETH_RX_SG_CB; 1087 card->options.rx_sg_cb = QETH_RX_SG_CB;
1078} 1088}
@@ -1682,6 +1692,7 @@ int qeth_send_control_data(struct qeth_card *card, int len,
1682 unsigned long flags; 1692 unsigned long flags;
1683 struct qeth_reply *reply = NULL; 1693 struct qeth_reply *reply = NULL;
1684 unsigned long timeout; 1694 unsigned long timeout;
1695 struct qeth_ipa_cmd *cmd;
1685 1696
1686 QETH_DBF_TEXT(TRACE, 2, "sendctl"); 1697 QETH_DBF_TEXT(TRACE, 2, "sendctl");
1687 1698
@@ -1728,17 +1739,34 @@ int qeth_send_control_data(struct qeth_card *card, int len,
1728 wake_up(&card->wait_q); 1739 wake_up(&card->wait_q);
1729 return rc; 1740 return rc;
1730 } 1741 }
1731 while (!atomic_read(&reply->received)) { 1742
1732 if (time_after(jiffies, timeout)) { 1743 /* we have only one long running ipassist, since we can ensure
1733 spin_lock_irqsave(&reply->card->lock, flags); 1744 process context of this command we can sleep */
1734 list_del_init(&reply->list); 1745 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1735 spin_unlock_irqrestore(&reply->card->lock, flags); 1746 if ((cmd->hdr.command == IPA_CMD_SETIP) &&
1736 reply->rc = -ETIME; 1747 (cmd->hdr.prot_version == QETH_PROT_IPV4)) {
1737 atomic_inc(&reply->received); 1748 if (!wait_event_timeout(reply->wait_q,
1738 wake_up(&reply->wait_q); 1749 atomic_read(&reply->received), timeout))
1739 } 1750 goto time_err;
1740 cpu_relax(); 1751 } else {
1741 }; 1752 while (!atomic_read(&reply->received)) {
1753 if (time_after(jiffies, timeout))
1754 goto time_err;
1755 cpu_relax();
1756 };
1757 }
1758
1759 rc = reply->rc;
1760 qeth_put_reply(reply);
1761 return rc;
1762
1763time_err:
1764 spin_lock_irqsave(&reply->card->lock, flags);
1765 list_del_init(&reply->list);
1766 spin_unlock_irqrestore(&reply->card->lock, flags);
1767 reply->rc = -ETIME;
1768 atomic_inc(&reply->received);
1769 wake_up(&reply->wait_q);
1742 rc = reply->rc; 1770 rc = reply->rc;
1743 qeth_put_reply(reply); 1771 qeth_put_reply(reply);
1744 return rc; 1772 return rc;
@@ -2250,7 +2278,8 @@ void qeth_print_status_message(struct qeth_card *card)
2250 } 2278 }
2251 /* fallthrough */ 2279 /* fallthrough */
2252 case QETH_CARD_TYPE_IQD: 2280 case QETH_CARD_TYPE_IQD:
2253 if (card->info.guestlan) { 2281 if ((card->info.guestlan) ||
2282 (card->info.mcl_level[0] & 0x80)) {
2254 card->info.mcl_level[0] = (char) _ebcasc[(__u8) 2283 card->info.mcl_level[0] = (char) _ebcasc[(__u8)
2255 card->info.mcl_level[0]]; 2284 card->info.mcl_level[0]];
2256 card->info.mcl_level[1] = (char) _ebcasc[(__u8) 2285 card->info.mcl_level[1] = (char) _ebcasc[(__u8)
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 2c48591ced44..21627ba3093b 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -1126,9 +1126,11 @@ static int qeth_l2_recover(void *ptr)
1126 dev_info(&card->gdev->dev, 1126 dev_info(&card->gdev->dev,
1127 "Device successfully recovered!\n"); 1127 "Device successfully recovered!\n");
1128 else { 1128 else {
1129 rtnl_lock(); 1129 if (card->dev) {
1130 dev_close(card->dev); 1130 rtnl_lock();
1131 rtnl_unlock(); 1131 dev_close(card->dev);
1132 rtnl_unlock();
1133 }
1132 dev_warn(&card->gdev->dev, "The qeth device driver " 1134 dev_warn(&card->gdev->dev, "The qeth device driver "
1133 "failed to recover an error on the device\n"); 1135 "failed to recover an error on the device\n");
1134 } 1136 }
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index c0b30b25a5f1..cfda1ecffdf2 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1047,7 +1047,7 @@ static int qeth_l3_setadapter_parms(struct qeth_card *card)
1047 rc = qeth_setadpparms_change_macaddr(card); 1047 rc = qeth_setadpparms_change_macaddr(card);
1048 if (rc) 1048 if (rc)
1049 dev_warn(&card->gdev->dev, "Reading the adapter MAC" 1049 dev_warn(&card->gdev->dev, "Reading the adapter MAC"
1050 " address failed\n", rc); 1050 " address failed\n");
1051 } 1051 }
1052 1052
1053 if ((card->info.link_type == QETH_LINK_TYPE_HSTR) || 1053 if ((card->info.link_type == QETH_LINK_TYPE_HSTR) ||
@@ -1207,12 +1207,9 @@ static int qeth_l3_start_ipa_source_mac(struct qeth_card *card)
1207 1207
1208 QETH_DBF_TEXT(TRACE, 3, "stsrcmac"); 1208 QETH_DBF_TEXT(TRACE, 3, "stsrcmac");
1209 1209
1210 if (!card->options.fake_ll)
1211 return -EOPNOTSUPP;
1212
1213 if (!qeth_is_supported(card, IPA_SOURCE_MAC)) { 1210 if (!qeth_is_supported(card, IPA_SOURCE_MAC)) {
1214 dev_info(&card->gdev->dev, 1211 dev_info(&card->gdev->dev,
1215 "Inbound source address not supported on %s\n", 1212 "Inbound source MAC-address not supported on %s\n",
1216 QETH_CARD_IFNAME(card)); 1213 QETH_CARD_IFNAME(card));
1217 return -EOPNOTSUPP; 1214 return -EOPNOTSUPP;
1218 } 1215 }
@@ -1221,7 +1218,7 @@ static int qeth_l3_start_ipa_source_mac(struct qeth_card *card)
1221 IPA_CMD_ASS_START, 0); 1218 IPA_CMD_ASS_START, 0);
1222 if (rc) 1219 if (rc)
1223 dev_warn(&card->gdev->dev, 1220 dev_warn(&card->gdev->dev,
1224 "Starting proxy ARP support for %s failed\n", 1221 "Starting source MAC-address support for %s failed\n",
1225 QETH_CARD_IFNAME(card)); 1222 QETH_CARD_IFNAME(card));
1226 return rc; 1223 return rc;
1227} 1224}
@@ -1921,8 +1918,13 @@ static inline __u16 qeth_l3_rebuild_skb(struct qeth_card *card,
1921 memcpy(tg_addr, card->dev->dev_addr, 1918 memcpy(tg_addr, card->dev->dev_addr,
1922 card->dev->addr_len); 1919 card->dev->addr_len);
1923 } 1920 }
1924 card->dev->header_ops->create(skb, card->dev, prot, tg_addr, 1921 if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
1925 "FAKELL", card->dev->addr_len); 1922 card->dev->header_ops->create(skb, card->dev, prot,
1923 tg_addr, &hdr->hdr.l3.dest_addr[2],
1924 card->dev->addr_len);
1925 else
1926 card->dev->header_ops->create(skb, card->dev, prot,
1927 tg_addr, "FAKELL", card->dev->addr_len);
1926 } 1928 }
1927 1929
1928#ifdef CONFIG_TR 1930#ifdef CONFIG_TR
@@ -2080,9 +2082,11 @@ static int qeth_l3_stop_card(struct qeth_card *card, int recovery_mode)
2080 if (recovery_mode) 2082 if (recovery_mode)
2081 qeth_l3_stop(card->dev); 2083 qeth_l3_stop(card->dev);
2082 else { 2084 else {
2083 rtnl_lock(); 2085 if (card->dev) {
2084 dev_close(card->dev); 2086 rtnl_lock();
2085 rtnl_unlock(); 2087 dev_close(card->dev);
2088 rtnl_unlock();
2089 }
2086 } 2090 }
2087 if (!card->use_hard_stop) { 2091 if (!card->use_hard_stop) {
2088 rc = qeth_send_stoplan(card); 2092 rc = qeth_send_stoplan(card);
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 185be760833e..2a129cb7bb56 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -279,7 +279,6 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
279 inode->i_mode = mode; 279 inode->i_mode = mode;
280 inode->i_uid = current_fsuid(); 280 inode->i_uid = current_fsuid();
281 inode->i_gid = current_fsgid(); 281 inode->i_gid = current_fsgid();
282 inode->i_blocks = 0;
283 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 282 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
284 switch (mode & S_IFMT) { 283 switch (mode & S_IFMT) {
285 default: 284 default:
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index c4e62a6297d7..2e71368f45b4 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1863,26 +1863,10 @@ static int do_write(struct fsg_dev *fsg)
1863static int fsync_sub(struct lun *curlun) 1863static int fsync_sub(struct lun *curlun)
1864{ 1864{
1865 struct file *filp = curlun->filp; 1865 struct file *filp = curlun->filp;
1866 struct inode *inode;
1867 int rc, err;
1868 1866
1869 if (curlun->ro || !filp) 1867 if (curlun->ro || !filp)
1870 return 0; 1868 return 0;
1871 if (!filp->f_op->fsync) 1869 return vfs_fsync(filp, filp->f_path.dentry, 1);
1872 return -EINVAL;
1873
1874 inode = filp->f_path.dentry->d_inode;
1875 mutex_lock(&inode->i_mutex);
1876 rc = filemap_fdatawrite(inode->i_mapping);
1877 err = filp->f_op->fsync(filp, filp->f_path.dentry, 1);
1878 if (!rc)
1879 rc = err;
1880 err = filemap_fdatawait(inode->i_mapping);
1881 if (!rc)
1882 rc = err;
1883 mutex_unlock(&inode->i_mutex);
1884 VLDBG(curlun, "fdatasync -> %d\n", rc);
1885 return rc;
1886} 1870}
1887 1871
1888static void fsync_all(struct fsg_dev *fsg) 1872static void fsync_all(struct fsg_dev *fsg)
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index eeb26c0f88e5..317b48fdbf01 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -2001,7 +2001,6 @@ gadgetfs_make_inode (struct super_block *sb,
2001 inode->i_mode = mode; 2001 inode->i_mode = mode;
2002 inode->i_uid = default_uid; 2002 inode->i_uid = default_uid;
2003 inode->i_gid = default_gid; 2003 inode->i_gid = default_gid;
2004 inode->i_blocks = 0;
2005 inode->i_atime = inode->i_mtime = inode->i_ctime 2004 inode->i_atime = inode->i_mtime = inode->i_ctime
2006 = CURRENT_TIME; 2005 = CURRENT_TIME;
2007 inode->i_private = data; 2006 inode->i_private = data;
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 73ac754ad801..e21fe5b6f9ff 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -546,23 +546,25 @@ static int viafb_blank(int blank_mode, struct fb_info *info)
546 546
547static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) 547static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
548{ 548{
549 struct viafb_ioctl_mode viamode; 549 union {
550 struct viafb_ioctl_samm viasamm; 550 struct viafb_ioctl_mode viamode;
551 struct viafb_driver_version driver_version; 551 struct viafb_ioctl_samm viasamm;
552 struct fb_var_screeninfo sec_var; 552 struct viafb_driver_version driver_version;
553 struct _panel_size_pos_info panel_pos_size_para; 553 struct fb_var_screeninfo sec_var;
554 struct _panel_size_pos_info panel_pos_size_para;
555 struct viafb_ioctl_setting viafb_setting;
556 struct device_t active_dev;
557 } u;
554 u32 state_info = 0; 558 u32 state_info = 0;
555 u32 viainfo_size = sizeof(struct viafb_ioctl_info);
556 u32 *viafb_gamma_table; 559 u32 *viafb_gamma_table;
557 char driver_name[] = "viafb"; 560 char driver_name[] = "viafb";
558 561
559 u32 __user *argp = (u32 __user *) arg; 562 u32 __user *argp = (u32 __user *) arg;
560 u32 gpu32; 563 u32 gpu32;
561 u32 video_dev_info = 0; 564 u32 video_dev_info = 0;
562 struct viafb_ioctl_setting viafb_setting = {};
563 struct device_t active_dev = {};
564 565
565 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); 566 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
567 memset(&u, 0, sizeof(u));
566 568
567 switch (cmd) { 569 switch (cmd) {
568 case VIAFB_GET_CHIP_INFO: 570 case VIAFB_GET_CHIP_INFO:
@@ -571,7 +573,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
571 return -EFAULT; 573 return -EFAULT;
572 break; 574 break;
573 case VIAFB_GET_INFO_SIZE: 575 case VIAFB_GET_INFO_SIZE:
574 return put_user(viainfo_size, argp); 576 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
575 case VIAFB_GET_INFO: 577 case VIAFB_GET_INFO:
576 return viafb_ioctl_get_viafb_info(arg); 578 return viafb_ioctl_get_viafb_info(arg);
577 case VIAFB_HOTPLUG: 579 case VIAFB_HOTPLUG:
@@ -584,60 +586,60 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
584 viafb_hotplug = (gpu32) ? 1 : 0; 586 viafb_hotplug = (gpu32) ? 1 : 0;
585 break; 587 break;
586 case VIAFB_GET_RESOLUTION: 588 case VIAFB_GET_RESOLUTION:
587 viamode.xres = (u32) viafb_hotplug_Xres; 589 u.viamode.xres = (u32) viafb_hotplug_Xres;
588 viamode.yres = (u32) viafb_hotplug_Yres; 590 u.viamode.yres = (u32) viafb_hotplug_Yres;
589 viamode.refresh = (u32) viafb_hotplug_refresh; 591 u.viamode.refresh = (u32) viafb_hotplug_refresh;
590 viamode.bpp = (u32) viafb_hotplug_bpp; 592 u.viamode.bpp = (u32) viafb_hotplug_bpp;
591 if (viafb_SAMM_ON == 1) { 593 if (viafb_SAMM_ON == 1) {
592 viamode.xres_sec = viafb_second_xres; 594 u.viamode.xres_sec = viafb_second_xres;
593 viamode.yres_sec = viafb_second_yres; 595 u.viamode.yres_sec = viafb_second_yres;
594 viamode.virtual_xres_sec = viafb_second_virtual_xres; 596 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
595 viamode.virtual_yres_sec = viafb_second_virtual_yres; 597 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
596 viamode.refresh_sec = viafb_refresh1; 598 u.viamode.refresh_sec = viafb_refresh1;
597 viamode.bpp_sec = viafb_bpp1; 599 u.viamode.bpp_sec = viafb_bpp1;
598 } else { 600 } else {
599 viamode.xres_sec = 0; 601 u.viamode.xres_sec = 0;
600 viamode.yres_sec = 0; 602 u.viamode.yres_sec = 0;
601 viamode.virtual_xres_sec = 0; 603 u.viamode.virtual_xres_sec = 0;
602 viamode.virtual_yres_sec = 0; 604 u.viamode.virtual_yres_sec = 0;
603 viamode.refresh_sec = 0; 605 u.viamode.refresh_sec = 0;
604 viamode.bpp_sec = 0; 606 u.viamode.bpp_sec = 0;
605 } 607 }
606 if (copy_to_user(argp, &viamode, sizeof(viamode))) 608 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
607 return -EFAULT; 609 return -EFAULT;
608 break; 610 break;
609 case VIAFB_GET_SAMM_INFO: 611 case VIAFB_GET_SAMM_INFO:
610 viasamm.samm_status = viafb_SAMM_ON; 612 u.viasamm.samm_status = viafb_SAMM_ON;
611 613
612 if (viafb_SAMM_ON == 1) { 614 if (viafb_SAMM_ON == 1) {
613 if (viafb_dual_fb) { 615 if (viafb_dual_fb) {
614 viasamm.size_prim = viaparinfo->fbmem_free; 616 u.viasamm.size_prim = viaparinfo->fbmem_free;
615 viasamm.size_sec = viaparinfo1->fbmem_free; 617 u.viasamm.size_sec = viaparinfo1->fbmem_free;
616 } else { 618 } else {
617 if (viafb_second_size) { 619 if (viafb_second_size) {
618 viasamm.size_prim = 620 u.viasamm.size_prim =
619 viaparinfo->fbmem_free - 621 viaparinfo->fbmem_free -
620 viafb_second_size * 1024 * 1024; 622 viafb_second_size * 1024 * 1024;
621 viasamm.size_sec = 623 u.viasamm.size_sec =
622 viafb_second_size * 1024 * 1024; 624 viafb_second_size * 1024 * 1024;
623 } else { 625 } else {
624 viasamm.size_prim = 626 u.viasamm.size_prim =
625 viaparinfo->fbmem_free >> 1; 627 viaparinfo->fbmem_free >> 1;
626 viasamm.size_sec = 628 u.viasamm.size_sec =
627 (viaparinfo->fbmem_free >> 1); 629 (viaparinfo->fbmem_free >> 1);
628 } 630 }
629 } 631 }
630 viasamm.mem_base = viaparinfo->fbmem; 632 u.viasamm.mem_base = viaparinfo->fbmem;
631 viasamm.offset_sec = viafb_second_offset; 633 u.viasamm.offset_sec = viafb_second_offset;
632 } else { 634 } else {
633 viasamm.size_prim = 635 u.viasamm.size_prim =
634 viaparinfo->memsize - viaparinfo->fbmem_used; 636 viaparinfo->memsize - viaparinfo->fbmem_used;
635 viasamm.size_sec = 0; 637 u.viasamm.size_sec = 0;
636 viasamm.mem_base = viaparinfo->fbmem; 638 u.viasamm.mem_base = viaparinfo->fbmem;
637 viasamm.offset_sec = 0; 639 u.viasamm.offset_sec = 0;
638 } 640 }
639 641
640 if (copy_to_user(argp, &viasamm, sizeof(viasamm))) 642 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
641 return -EFAULT; 643 return -EFAULT;
642 644
643 break; 645 break;
@@ -662,74 +664,75 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
662 viafb_lcd_disable(); 664 viafb_lcd_disable();
663 break; 665 break;
664 case VIAFB_SET_DEVICE: 666 case VIAFB_SET_DEVICE:
665 if (copy_from_user(&active_dev, (void *)argp, 667 if (copy_from_user(&u.active_dev, (void *)argp,
666 sizeof(active_dev))) 668 sizeof(u.active_dev)))
667 return -EFAULT; 669 return -EFAULT;
668 viafb_set_device(active_dev); 670 viafb_set_device(u.active_dev);
669 viafb_set_par(info); 671 viafb_set_par(info);
670 break; 672 break;
671 case VIAFB_GET_DEVICE: 673 case VIAFB_GET_DEVICE:
672 active_dev.crt = viafb_CRT_ON; 674 u.active_dev.crt = viafb_CRT_ON;
673 active_dev.dvi = viafb_DVI_ON; 675 u.active_dev.dvi = viafb_DVI_ON;
674 active_dev.lcd = viafb_LCD_ON; 676 u.active_dev.lcd = viafb_LCD_ON;
675 active_dev.samm = viafb_SAMM_ON; 677 u.active_dev.samm = viafb_SAMM_ON;
676 active_dev.primary_dev = viafb_primary_dev; 678 u.active_dev.primary_dev = viafb_primary_dev;
677 679
678 active_dev.lcd_dsp_cent = viafb_lcd_dsp_method; 680 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
679 active_dev.lcd_panel_id = viafb_lcd_panel_id; 681 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
680 active_dev.lcd_mode = viafb_lcd_mode; 682 u.active_dev.lcd_mode = viafb_lcd_mode;
681 683
682 active_dev.xres = viafb_hotplug_Xres; 684 u.active_dev.xres = viafb_hotplug_Xres;
683 active_dev.yres = viafb_hotplug_Yres; 685 u.active_dev.yres = viafb_hotplug_Yres;
684 686
685 active_dev.xres1 = viafb_second_xres; 687 u.active_dev.xres1 = viafb_second_xres;
686 active_dev.yres1 = viafb_second_yres; 688 u.active_dev.yres1 = viafb_second_yres;
687 689
688 active_dev.bpp = viafb_bpp; 690 u.active_dev.bpp = viafb_bpp;
689 active_dev.bpp1 = viafb_bpp1; 691 u.active_dev.bpp1 = viafb_bpp1;
690 active_dev.refresh = viafb_refresh; 692 u.active_dev.refresh = viafb_refresh;
691 active_dev.refresh1 = viafb_refresh1; 693 u.active_dev.refresh1 = viafb_refresh1;
692 694
693 active_dev.epia_dvi = viafb_platform_epia_dvi; 695 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
694 active_dev.lcd_dual_edge = viafb_device_lcd_dualedge; 696 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
695 active_dev.bus_width = viafb_bus_width; 697 u.active_dev.bus_width = viafb_bus_width;
696 698
697 if (copy_to_user(argp, &active_dev, sizeof(active_dev))) 699 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
698 return -EFAULT; 700 return -EFAULT;
699 break; 701 break;
700 702
701 case VIAFB_GET_DRIVER_VERSION: 703 case VIAFB_GET_DRIVER_VERSION:
702 driver_version.iMajorNum = VERSION_MAJOR; 704 u.driver_version.iMajorNum = VERSION_MAJOR;
703 driver_version.iKernelNum = VERSION_KERNEL; 705 u.driver_version.iKernelNum = VERSION_KERNEL;
704 driver_version.iOSNum = VERSION_OS; 706 u.driver_version.iOSNum = VERSION_OS;
705 driver_version.iMinorNum = VERSION_MINOR; 707 u.driver_version.iMinorNum = VERSION_MINOR;
706 708
707 if (copy_to_user(argp, &driver_version, 709 if (copy_to_user(argp, &u.driver_version,
708 sizeof(driver_version))) 710 sizeof(u.driver_version)))
709 return -EFAULT; 711 return -EFAULT;
710 712
711 break; 713 break;
712 714
713 case VIAFB_SET_DEVICE_INFO: 715 case VIAFB_SET_DEVICE_INFO:
714 if (copy_from_user(&viafb_setting, 716 if (copy_from_user(&u.viafb_setting,
715 argp, sizeof(viafb_setting))) 717 argp, sizeof(u.viafb_setting)))
716 return -EFAULT; 718 return -EFAULT;
717 if (apply_device_setting(viafb_setting, info) < 0) 719 if (apply_device_setting(u.viafb_setting, info) < 0)
718 return -EINVAL; 720 return -EINVAL;
719 721
720 break; 722 break;
721 723
722 case VIAFB_SET_SECOND_MODE: 724 case VIAFB_SET_SECOND_MODE:
723 if (copy_from_user(&sec_var, argp, sizeof(sec_var))) 725 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
724 return -EFAULT; 726 return -EFAULT;
725 apply_second_mode_setting(&sec_var); 727 apply_second_mode_setting(&u.sec_var);
726 break; 728 break;
727 729
728 case VIAFB_GET_DEVICE_INFO: 730 case VIAFB_GET_DEVICE_INFO:
729 731
730 retrieve_device_setting(&viafb_setting); 732 retrieve_device_setting(&u.viafb_setting);
731 733
732 if (copy_to_user(argp, &viafb_setting, sizeof(viafb_setting))) 734 if (copy_to_user(argp, &u.viafb_setting,
735 sizeof(u.viafb_setting)))
733 return -EFAULT; 736 return -EFAULT;
734 737
735 break; 738 break;
@@ -806,51 +809,51 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
806 break; 809 break;
807 810
808 case VIAFB_GET_PANEL_MAX_SIZE: 811 case VIAFB_GET_PANEL_MAX_SIZE:
809 if (copy_from_user 812 if (copy_from_user(&u.panel_pos_size_para, argp,
810 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 813 sizeof(u.panel_pos_size_para)))
811 return -EFAULT; 814 return -EFAULT;
812 panel_pos_size_para.x = panel_pos_size_para.y = 0; 815 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
813 if (copy_to_user(argp, &panel_pos_size_para, 816 if (copy_to_user(argp, &u.panel_pos_size_para,
814 sizeof(panel_pos_size_para))) 817 sizeof(u.panel_pos_size_para)))
815 return -EFAULT; 818 return -EFAULT;
816 break; 819 break;
817 case VIAFB_GET_PANEL_MAX_POSITION: 820 case VIAFB_GET_PANEL_MAX_POSITION:
818 if (copy_from_user 821 if (copy_from_user(&u.panel_pos_size_para, argp,
819 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 822 sizeof(u.panel_pos_size_para)))
820 return -EFAULT; 823 return -EFAULT;
821 panel_pos_size_para.x = panel_pos_size_para.y = 0; 824 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
822 if (copy_to_user(argp, &panel_pos_size_para, 825 if (copy_to_user(argp, &u.panel_pos_size_para,
823 sizeof(panel_pos_size_para))) 826 sizeof(u.panel_pos_size_para)))
824 return -EFAULT; 827 return -EFAULT;
825 break; 828 break;
826 829
827 case VIAFB_GET_PANEL_POSITION: 830 case VIAFB_GET_PANEL_POSITION:
828 if (copy_from_user 831 if (copy_from_user(&u.panel_pos_size_para, argp,
829 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 832 sizeof(u.panel_pos_size_para)))
830 return -EFAULT; 833 return -EFAULT;
831 panel_pos_size_para.x = panel_pos_size_para.y = 0; 834 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
832 if (copy_to_user(argp, &panel_pos_size_para, 835 if (copy_to_user(argp, &u.panel_pos_size_para,
833 sizeof(panel_pos_size_para))) 836 sizeof(u.panel_pos_size_para)))
834 return -EFAULT; 837 return -EFAULT;
835 break; 838 break;
836 case VIAFB_GET_PANEL_SIZE: 839 case VIAFB_GET_PANEL_SIZE:
837 if (copy_from_user 840 if (copy_from_user(&u.panel_pos_size_para, argp,
838 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 841 sizeof(u.panel_pos_size_para)))
839 return -EFAULT; 842 return -EFAULT;
840 panel_pos_size_para.x = panel_pos_size_para.y = 0; 843 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
841 if (copy_to_user(argp, &panel_pos_size_para, 844 if (copy_to_user(argp, &u.panel_pos_size_para,
842 sizeof(panel_pos_size_para))) 845 sizeof(u.panel_pos_size_para)))
843 return -EFAULT; 846 return -EFAULT;
844 break; 847 break;
845 848
846 case VIAFB_SET_PANEL_POSITION: 849 case VIAFB_SET_PANEL_POSITION:
847 if (copy_from_user 850 if (copy_from_user(&u.panel_pos_size_para, argp,
848 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 851 sizeof(u.panel_pos_size_para)))
849 return -EFAULT; 852 return -EFAULT;
850 break; 853 break;
851 case VIAFB_SET_PANEL_SIZE: 854 case VIAFB_SET_PANEL_SIZE:
852 if (copy_from_user 855 if (copy_from_user(&u.panel_pos_size_para, argp,
853 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 856 sizeof(u.panel_pos_size_para)))
854 return -EFAULT; 857 return -EFAULT;
855 break; 858 break;
856 859
@@ -1052,10 +1055,8 @@ static void viafb_imageblit(struct fb_info *info,
1052 1055
1053static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) 1056static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1054{ 1057{
1055 u8 data[CURSOR_SIZE / 8];
1056 u32 data_bak[CURSOR_SIZE / 32];
1057 u32 temp, xx, yy, bg_col = 0, fg_col = 0; 1058 u32 temp, xx, yy, bg_col = 0, fg_col = 0;
1058 int size, i, j = 0; 1059 int i, j = 0;
1059 static int hw_cursor; 1060 static int hw_cursor;
1060 struct viafb_par *p_viafb_par; 1061 struct viafb_par *p_viafb_par;
1061 1062
@@ -1178,22 +1179,29 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1178 } 1179 }
1179 1180
1180 if (cursor->set & FB_CUR_SETSHAPE) { 1181 if (cursor->set & FB_CUR_SETSHAPE) {
1181 size = 1182 struct {
1183 u8 data[CURSOR_SIZE / 8];
1184 u32 bak[CURSOR_SIZE / 32];
1185 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
1186 int size =
1182 ((viacursor.image.width + 7) >> 3) * 1187 ((viacursor.image.width + 7) >> 3) *
1183 viacursor.image.height; 1188 viacursor.image.height;
1184 1189
1190 if (cr_data == NULL)
1191 goto out;
1192
1185 if (MAX_CURS == 32) { 1193 if (MAX_CURS == 32) {
1186 for (i = 0; i < (CURSOR_SIZE / 32); i++) { 1194 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1187 data_bak[i] = 0x0; 1195 cr_data->bak[i] = 0x0;
1188 data_bak[i + 1] = 0xFFFFFFFF; 1196 cr_data->bak[i + 1] = 0xFFFFFFFF;
1189 i += 1; 1197 i += 1;
1190 } 1198 }
1191 } else if (MAX_CURS == 64) { 1199 } else if (MAX_CURS == 64) {
1192 for (i = 0; i < (CURSOR_SIZE / 32); i++) { 1200 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1193 data_bak[i] = 0x0; 1201 cr_data->bak[i] = 0x0;
1194 data_bak[i + 1] = 0x0; 1202 cr_data->bak[i + 1] = 0x0;
1195 data_bak[i + 2] = 0xFFFFFFFF; 1203 cr_data->bak[i + 2] = 0xFFFFFFFF;
1196 data_bak[i + 3] = 0xFFFFFFFF; 1204 cr_data->bak[i + 3] = 0xFFFFFFFF;
1197 i += 3; 1205 i += 3;
1198 } 1206 }
1199 } 1207 }
@@ -1201,12 +1209,12 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1201 switch (viacursor.rop) { 1209 switch (viacursor.rop) {
1202 case ROP_XOR: 1210 case ROP_XOR:
1203 for (i = 0; i < size; i++) 1211 for (i = 0; i < size; i++)
1204 data[i] = viacursor.mask[i]; 1212 cr_data->data[i] = viacursor.mask[i];
1205 break; 1213 break;
1206 case ROP_COPY: 1214 case ROP_COPY:
1207 1215
1208 for (i = 0; i < size; i++) 1216 for (i = 0; i < size; i++)
1209 data[i] = viacursor.mask[i]; 1217 cr_data->data[i] = viacursor.mask[i];
1210 break; 1218 break;
1211 default: 1219 default:
1212 break; 1220 break;
@@ -1214,23 +1222,25 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1214 1222
1215 if (MAX_CURS == 32) { 1223 if (MAX_CURS == 32) {
1216 for (i = 0; i < size; i++) { 1224 for (i = 0; i < size; i++) {
1217 data_bak[j] = (u32) data[i]; 1225 cr_data->bak[j] = (u32) cr_data->data[i];
1218 data_bak[j + 1] = ~data_bak[j]; 1226 cr_data->bak[j + 1] = ~cr_data->bak[j];
1219 j += 2; 1227 j += 2;
1220 } 1228 }
1221 } else if (MAX_CURS == 64) { 1229 } else if (MAX_CURS == 64) {
1222 for (i = 0; i < size; i++) { 1230 for (i = 0; i < size; i++) {
1223 data_bak[j] = (u32) data[i]; 1231 cr_data->bak[j] = (u32) cr_data->data[i];
1224 data_bak[j + 1] = 0x0; 1232 cr_data->bak[j + 1] = 0x0;
1225 data_bak[j + 2] = ~data_bak[j]; 1233 cr_data->bak[j + 2] = ~cr_data->bak[j];
1226 data_bak[j + 3] = ~data_bak[j + 1]; 1234 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
1227 j += 4; 1235 j += 4;
1228 } 1236 }
1229 } 1237 }
1230 1238
1231 memcpy(((struct viafb_par *)(info->par))->fbmem_virt + 1239 memcpy(((struct viafb_par *)(info->par))->fbmem_virt +
1232 ((struct viafb_par *)(info->par))->cursor_start, 1240 ((struct viafb_par *)(info->par))->cursor_start,
1233 data_bak, CURSOR_SIZE); 1241 cr_data->bak, CURSOR_SIZE);
1242out:
1243 kfree(cr_data);
1234 } 1244 }
1235 1245
1236 if (viacursor.enable) 1246 if (viacursor.enable)