aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/glue.c112
-rw-r--r--drivers/block/ataflop.c4
-rw-r--r--drivers/char/vt.c5
-rw-r--r--drivers/hid/Kconfig221
-rw-r--r--drivers/hid/Makefile35
-rw-r--r--drivers/hid/hid-a4tech.c162
-rw-r--r--drivers/hid/hid-apple.c484
-rw-r--r--drivers/hid/hid-belkin.c105
-rw-r--r--drivers/hid/hid-bright.c71
-rw-r--r--drivers/hid/hid-cherry.c87
-rw-r--r--drivers/hid/hid-chicony.c80
-rw-r--r--drivers/hid/hid-core.c1181
-rw-r--r--drivers/hid/hid-cypress.c158
-rw-r--r--drivers/hid/hid-dell.c75
-rw-r--r--drivers/hid/hid-dummy.c72
-rw-r--r--drivers/hid/hid-ezkey.c95
-rw-r--r--drivers/hid/hid-gyration.c96
-rw-r--r--drivers/hid/hid-ids.h404
-rw-r--r--drivers/hid/hid-input-quirks.c484
-rw-r--r--drivers/hid/hid-input.c915
-rw-r--r--drivers/hid/hid-lg.c342
-rw-r--r--drivers/hid/hid-lg.h18
-rw-r--r--drivers/hid/hid-lg2ff.c (renamed from drivers/hid/usbhid/hid-lg2ff.c)14
-rw-r--r--drivers/hid/hid-lgff.c (renamed from drivers/hid/usbhid/hid-lgff.c)34
-rw-r--r--drivers/hid/hid-microsoft.c219
-rw-r--r--drivers/hid/hid-monterey.c82
-rw-r--r--drivers/hid/hid-petalynx.c122
-rw-r--r--drivers/hid/hid-pl.c (renamed from drivers/hid/usbhid/hid-plff.c)83
-rw-r--r--drivers/hid/hid-samsung.c100
-rw-r--r--drivers/hid/hid-sony.c110
-rw-r--r--drivers/hid/hid-sunplus.c82
-rw-r--r--drivers/hid/hid-tmff.c (renamed from drivers/hid/usbhid/hid-tmff.c)138
-rw-r--r--drivers/hid/hid-zpff.c (renamed from drivers/hid/usbhid/hid-zpff.c)71
-rw-r--r--drivers/hid/hidraw.c8
-rw-r--r--drivers/hid/usbhid/Kconfig75
-rw-r--r--drivers/hid/usbhid/Makefile18
-rw-r--r--drivers/hid/usbhid/hid-core.c463
-rw-r--r--drivers/hid/usbhid/hid-ff.c95
-rw-r--r--drivers/hid/usbhid/hid-pidff.c5
-rw-r--r--drivers/hid/usbhid/hid-quirks.c934
-rw-r--r--drivers/hid/usbhid/hiddev.c20
-rw-r--r--drivers/hid/usbhid/usbhid.h4
-rw-r--r--drivers/hid/usbhid/usbkbd.c12
-rw-r--r--drivers/hid/usbhid/usbmouse.c8
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c10
-rw-r--r--drivers/input/serio/hp_sdc.c2
-rw-r--r--drivers/isdn/mISDN/dsp_cmx.c4
-rw-r--r--drivers/isdn/mISDN/timerdev.c2
-rw-r--r--drivers/md/Kconfig14
-rw-r--r--drivers/mfd/Kconfig38
-rw-r--r--drivers/mfd/Makefile5
-rw-r--r--drivers/mfd/wm8350-core.c1273
-rw-r--r--drivers/mfd/wm8350-gpio.c222
-rw-r--r--drivers/mfd/wm8350-i2c.c120
-rw-r--r--drivers/mfd/wm8350-regmap.c1347
-rw-r--r--drivers/mfd/wm8400-core.c455
-rw-r--r--drivers/net/3c501.c12
-rw-r--r--drivers/net/3c515.c2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/appletalk/cops.c2
-rw-r--r--drivers/net/cxgb3/adapter.h2
-rw-r--r--drivers/net/cxgb3/ael1002.c2
-rw-r--r--drivers/net/cxgb3/common.h2
-rw-r--r--drivers/net/cxgb3/cxgb3_ctl_defs.h2
-rw-r--r--drivers/net/cxgb3/cxgb3_defs.h2
-rw-r--r--drivers/net/cxgb3/cxgb3_ioctl.h2
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c2
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c2
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.h2
-rw-r--r--drivers/net/cxgb3/firmware_exports.h2
-rw-r--r--drivers/net/cxgb3/l2t.c2
-rw-r--r--drivers/net/cxgb3/l2t.h2
-rw-r--r--drivers/net/cxgb3/mc5.c2
-rw-r--r--drivers/net/cxgb3/sge.c2
-rw-r--r--drivers/net/cxgb3/t3_cpl.h2
-rw-r--r--drivers/net/cxgb3/t3_hw.c2
-rw-r--r--drivers/net/cxgb3/t3cdev.h2
-rw-r--r--drivers/net/cxgb3/version.h4
-rw-r--r--drivers/net/cxgb3/vsc8211.c2
-rw-r--r--drivers/net/cxgb3/xgmac.c2
-rw-r--r--drivers/net/eexpress.c2
-rw-r--r--drivers/net/enic/enic_main.c1
-rw-r--r--drivers/net/ibmlana.c2
-rw-r--r--drivers/net/jme.c1
-rw-r--r--drivers/net/macmace.c2
-rw-r--r--drivers/net/pcmcia/3c589_cs.c2
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c2
-rw-r--r--drivers/net/phy/mdio_bus.c1
-rw-r--r--drivers/net/phy/phy_device.c1
-rw-r--r--drivers/net/qlge/qlge.h2
-rw-r--r--drivers/net/qlge/qlge_main.c1
-rw-r--r--drivers/net/tlan.c3
-rw-r--r--drivers/net/tokenring/smctr.c2
-rw-r--r--drivers/net/tulip/de2104x.c1
-rw-r--r--drivers/net/tulip/dmfe.c4
-rw-r--r--drivers/net/via-velocity.c2
-rw-r--r--drivers/net/wan/z85230.c3
-rw-r--r--drivers/net/wan/z85230.h2
-rw-r--r--drivers/net/wireless/wavelan.c2
-rw-r--r--drivers/net/wireless/wavelan.p.h2
-rw-r--r--drivers/regulator/Kconfig24
-rw-r--r--drivers/regulator/Makefile3
-rw-r--r--drivers/regulator/bq24022.c21
-rw-r--r--drivers/regulator/core.c508
-rw-r--r--drivers/regulator/da903x.c513
-rw-r--r--drivers/regulator/wm8350-regulator.c1431
-rw-r--r--drivers/regulator/wm8400-regulator.c368
-rw-r--r--drivers/rtc/rtc-cmos.c122
-rw-r--r--drivers/s390/net/claw.c2
-rw-r--r--drivers/scsi/Kconfig9
-rw-r--r--drivers/scsi/atari_dma_emul.c468
-rw-r--r--drivers/scsi/atari_scsi.c27
-rw-r--r--drivers/serial/8250.c3
-rw-r--r--drivers/video/console/fbcon.c39
-rw-r--r--drivers/video/console/mdacon.c2
-rw-r--r--drivers/video/console/sticon.c4
-rw-r--r--drivers/video/console/vgacon.c4
117 files changed, 11305 insertions, 3736 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 3c578ef78c48..24649ada08df 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -260,115 +260,3 @@ static int __init init_acpi_device_notify(void)
260} 260}
261 261
262arch_initcall(init_acpi_device_notify); 262arch_initcall(init_acpi_device_notify);
263
264
265#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE)
266
267#ifdef CONFIG_PM
268static u32 rtc_handler(void *context)
269{
270 acpi_clear_event(ACPI_EVENT_RTC);
271 acpi_disable_event(ACPI_EVENT_RTC, 0);
272 return ACPI_INTERRUPT_HANDLED;
273}
274
275static inline void rtc_wake_setup(void)
276{
277 acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
278 /*
279 * After the RTC handler is installed, the Fixed_RTC event should
280 * be disabled. Only when the RTC alarm is set will it be enabled.
281 */
282 acpi_clear_event(ACPI_EVENT_RTC);
283 acpi_disable_event(ACPI_EVENT_RTC, 0);
284}
285
286static void rtc_wake_on(struct device *dev)
287{
288 acpi_clear_event(ACPI_EVENT_RTC);
289 acpi_enable_event(ACPI_EVENT_RTC, 0);
290}
291
292static void rtc_wake_off(struct device *dev)
293{
294 acpi_disable_event(ACPI_EVENT_RTC, 0);
295}
296#else
297#define rtc_wake_setup() do{}while(0)
298#define rtc_wake_on NULL
299#define rtc_wake_off NULL
300#endif
301
302/* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find
303 * its device node and pass extra config data. This helps its driver use
304 * capabilities that the now-obsolete mc146818 didn't have, and informs it
305 * that this board's RTC is wakeup-capable (per ACPI spec).
306 */
307#include <linux/mc146818rtc.h>
308
309static struct cmos_rtc_board_info rtc_info;
310
311
312/* PNP devices are registered in a subsys_initcall();
313 * ACPI specifies the PNP IDs to use.
314 */
315#include <linux/pnp.h>
316
317static int __init pnp_match(struct device *dev, void *data)
318{
319 static const char *ids[] = { "PNP0b00", "PNP0b01", "PNP0b02", };
320 struct pnp_dev *pnp = to_pnp_dev(dev);
321 int i;
322
323 for (i = 0; i < ARRAY_SIZE(ids); i++) {
324 if (compare_pnp_id(pnp->id, ids[i]) != 0)
325 return 1;
326 }
327 return 0;
328}
329
330static struct device *__init get_rtc_dev(void)
331{
332 return bus_find_device(&pnp_bus_type, NULL, NULL, pnp_match);
333}
334
335static int __init acpi_rtc_init(void)
336{
337 struct device *dev = get_rtc_dev();
338
339 if (acpi_disabled)
340 return 0;
341
342 if (dev) {
343 rtc_wake_setup();
344 rtc_info.wake_on = rtc_wake_on;
345 rtc_info.wake_off = rtc_wake_off;
346
347 /* workaround bug in some ACPI tables */
348 if (acpi_gbl_FADT.month_alarm && !acpi_gbl_FADT.day_alarm) {
349 DBG("bogus FADT month_alarm\n");
350 acpi_gbl_FADT.month_alarm = 0;
351 }
352
353 rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm;
354 rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm;
355 rtc_info.rtc_century = acpi_gbl_FADT.century;
356
357 /* NOTE: S4_RTC_WAKE is NOT currently useful to Linux */
358 if (acpi_gbl_FADT.flags & ACPI_FADT_S4_RTC_WAKE)
359 printk(PREFIX "RTC can wake from S4\n");
360
361
362 dev->platform_data = &rtc_info;
363
364 /* RTC always wakes from S1/S2/S3, and often S4/STD */
365 device_init_wakeup(dev, 1);
366
367 put_device(dev);
368 } else
369 DBG("RTC unavailable?\n");
370 return 0;
371}
372module_init(acpi_rtc_init);
373
374#endif
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 49f274197b16..432cf4018291 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1882,10 +1882,6 @@ static int __init atari_floppy_init (void)
1882 /* Amiga, Mac, ... don't have Atari-compatible floppy :-) */ 1882 /* Amiga, Mac, ... don't have Atari-compatible floppy :-) */
1883 return -ENODEV; 1883 return -ENODEV;
1884 1884
1885 if (MACH_IS_HADES)
1886 /* Hades doesn't have Atari-compatible floppy */
1887 return -ENODEV;
1888
1889 if (register_blkdev(FLOPPY_MAJOR,"fd")) 1885 if (register_blkdev(FLOPPY_MAJOR,"fd"))
1890 return -EBUSY; 1886 return -EBUSY;
1891 1887
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 57029fefd64a..a0f7ffb68087 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -301,7 +301,7 @@ static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr)
301 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); 301 d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t);
302 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); 302 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr));
303 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); 303 scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row);
304 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_scrl_erase_char, 304 scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_video_erase_char,
305 vc->vc_size_row * nr); 305 vc->vc_size_row * nr);
306} 306}
307 307
@@ -319,7 +319,7 @@ static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr)
319 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); 319 s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t);
320 step = vc->vc_cols * nr; 320 step = vc->vc_cols * nr;
321 scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row); 321 scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row);
322 scr_memsetw(s, vc->vc_scrl_erase_char, 2 * step); 322 scr_memsetw(s, vc->vc_video_erase_char, 2 * step);
323} 323}
324 324
325static void do_update_region(struct vc_data *vc, unsigned long start, int count) 325static void do_update_region(struct vc_data *vc, unsigned long start, int count)
@@ -434,7 +434,6 @@ static void update_attr(struct vc_data *vc)
434 vc->vc_blink, vc->vc_underline, 434 vc->vc_blink, vc->vc_underline,
435 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic); 435 vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic);
436 vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << 8) | ' '; 436 vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << 8) | ' ';
437 vc->vc_scrl_erase_char = (build_attr(vc, vc->vc_def_color, 1, false, false, vc->vc_decscnm, false) << 8) | ' ';
438} 437}
439 438
440/* Note: inverting the screen twice should revert to the original state */ 439/* Note: inverting the screen twice should revert to the original state */
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index cacf89e65af4..da64108de775 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -17,6 +17,25 @@ config HID
17 tristate "Generic HID support" 17 tristate "Generic HID support"
18 depends on INPUT 18 depends on INPUT
19 default y 19 default y
20 select HID_A4TECH if !EMBEDDED
21 select HID_APPLE if !EMBEDDED
22 select HID_BELKIN if !EMBEDDED
23 select HID_BRIGHT if !EMBEDDED
24 select HID_CHERRY if !EMBEDDED
25 select HID_CHICONY if !EMBEDDED
26 select HID_CYPRESS if !EMBEDDED
27 select HID_DELL if !EMBEDDED
28 select HID_EZKEY if !EMBEDDED
29 select HID_GYRATION if !EMBEDDED
30 select HID_LOGITECH if !EMBEDDED
31 select HID_MICROSOFT if !EMBEDDED
32 select HID_MONTEREY if !EMBEDDED
33 select HID_PANTHERLORD if !EMBEDDED
34 select HID_PETALYNX if !EMBEDDED
35 select HID_SAMSUNG if !EMBEDDED
36 select HID_SONY if !EMBEDDED
37 select HID_SUNPLUS if !EMBEDDED
38
20 ---help--- 39 ---help---
21 A human interface device (HID) is a type of computer device that 40 A human interface device (HID) is a type of computer device that
22 interacts directly with and takes input from humans. The term "HID" 41 interacts directly with and takes input from humans. The term "HID"
@@ -67,4 +86,206 @@ config HIDRAW
67 86
68source "drivers/hid/usbhid/Kconfig" 87source "drivers/hid/usbhid/Kconfig"
69 88
89menu "Special HID drivers"
90 depends on HID
91
92config HID_COMPAT
93 bool "Load all HID drivers on hid core load"
94 default y
95 ---help---
96 Compatible option for older userspace. If you have system without udev
97 support of module loading through aliases and also old
98 module-init-tools which can't handle hid bus, choose Y here. Otherwise
99 say N. If you say N and your userspace is old enough, the only
100 functionality you lose is modules autoloading.
101
102 If unsure, say Y.
103
104config HID_A4TECH
105 tristate "A4 tech"
106 default m
107 depends on USB_HID
108 ---help---
109 Support for A4 tech X5 and WOP-35 / Trust 450L mice.
110
111config HID_APPLE
112 tristate "Apple"
113 default m
114 depends on (USB_HID || BT_HIDP)
115 ---help---
116 Support for some Apple devices which less or more break
117 HID specification.
118
119 Say Y here if you want support for the special keys (Fn, Numlock) on
120 Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB
121 keyboards.
122
123 If unsure, say M.
124
125config HID_BELKIN
126 tristate "Belkin"
127 default m
128 depends on USB_HID
129 ---help---
130 Support for Belkin Flip KVM and Wireless keyboard.
131
132config HID_BRIGHT
133 tristate "Bright"
134 default m
135 depends on USB_HID
136 ---help---
137 Support for Bright ABNT-2 keyboard.
138
139config HID_CHERRY
140 tristate "Cherry"
141 default m
142 depends on USB_HID
143 ---help---
144 Support for Cherry Cymotion.
145
146config HID_CHICONY
147 tristate "Chicony"
148 default m
149 depends on USB_HID
150 ---help---
151 Support for Chicony Tactical pad.
152
153config HID_CYPRESS
154 tristate "Cypress"
155 default m
156 depends on USB_HID
157 ---help---
158 Support for Cypress mouse and barcodes.
159
160config HID_DELL
161 tristate "Dell"
162 default m
163 depends on USB_HID
164 ---help---
165 Support for Dell W7658.
166
167config HID_EZKEY
168 tristate "Ezkey"
169 default m
170 depends on USB_HID
171 ---help---
172 Support for Ezkey mouse and barcodes.
173
174config HID_GYRATION
175 tristate "Gyration"
176 default m
177 depends on USB_HID
178 ---help---
179 Support for Gyration remote.
180
181config HID_LOGITECH
182 tristate "Logitech"
183 default m
184 depends on USB_HID
185 ---help---
186 Support for some Logitech devices which breaks less or more
187 HID specification.
188
189config LOGITECH_FF
190 bool "Logitech force feedback"
191 depends on HID_LOGITECH
192 select INPUT_FF_MEMLESS
193 help
194 Say Y here if you have one of these devices:
195 - Logitech WingMan Cordless RumblePad
196 - Logitech WingMan Cordless RumblePad 2
197 - Logitech WingMan Force 3D
198 - Logitech Formula Force EX
199 - Logitech MOMO Force wheel
200
201 and if you want to enable force feedback for them.
202 Note: if you say N here, this device will still be supported, but without
203 force feedback.
204
205config LOGIRUMBLEPAD2_FF
206 bool "Logitech Rumblepad 2 force feedback"
207 depends on HID_LOGITECH
208 select INPUT_FF_MEMLESS
209 help
210 Say Y here if you want to enable force feedback support for Logitech
211 Rumblepad 2 devices.
212
213config HID_MICROSOFT
214 tristate "Microsoft"
215 default m
216 depends on USB_HID
217 ---help---
218 Support for some Microsoft devices which breaks less or more
219 HID specification.
220
221config HID_MONTEREY
222 tristate "Monterey"
223 default m
224 depends on USB_HID
225 ---help---
226 Support for Monterey Genius KB29E.
227
228config HID_PANTHERLORD
229 tristate "Pantherlord devices support"
230 default m
231 depends on USB_HID
232 ---help---
233 Support for PantherLord/GreenAsia based device support.
234
235
236config PANTHERLORD_FF
237 bool "Pantherlord force feedback support"
238 depends on HID_PANTHERLORD
239 select INPUT_FF_MEMLESS
240 help
241 Say Y here if you have a PantherLord/GreenAsia based game controller
242 or adapter and want to enable force feedback support for it.
243
244config HID_PETALYNX
245 tristate "Petalynx"
246 default m
247 depends on USB_HID
248 ---help---
249 Support for Petalynx Maxter remote.
250
251config HID_SAMSUNG
252 tristate "Samsung"
253 default m
254 depends on USB_HID
255 ---help---
256 Support for Samsung IR remote.
257
258config HID_SONY
259 tristate "Sony"
260 default m
261 depends on USB_HID
262 ---help---
263 Support for Sony PS3 controller.
264
265config HID_SUNPLUS
266 tristate "Sunplus"
267 default m
268 depends on USB_HID
269 ---help---
270 Support for Sunplus WDesktop input device.
271
272config THRUSTMASTER_FF
273 tristate "ThrustMaster devices support"
274 default m
275 depends on USB_HID
276 select INPUT_FF_MEMLESS
277 help
278 Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
279 a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel.
280
281config ZEROPLUS_FF
282 tristate "Zeroplus based game controller support"
283 default m
284 depends on USB_HID
285 select INPUT_FF_MEMLESS
286 help
287 Say Y here if you have a Zeroplus based game controller.
288
289endmenu
290
70endif # HID_SUPPORT 291endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 275dc522c738..b09e43e7413e 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -1,13 +1,46 @@
1# 1#
2# Makefile for the HID driver 2# Makefile for the HID driver
3# 3#
4hid-objs := hid-core.o hid-input.o hid-input-quirks.o 4hid-objs := hid-core.o hid-input.o
5 5
6obj-$(CONFIG_HID) += hid.o 6obj-$(CONFIG_HID) += hid.o
7 7
8hid-$(CONFIG_HID_DEBUG) += hid-debug.o 8hid-$(CONFIG_HID_DEBUG) += hid-debug.o
9hid-$(CONFIG_HIDRAW) += hidraw.o 9hid-$(CONFIG_HIDRAW) += hidraw.o
10 10
11ifdef CONFIG_HID_COMPAT
12obj-m += hid-dummy.o
13endif
14
15hid-logitech-objs := hid-lg.o
16ifdef CONFIG_LOGITECH_FF
17 hid-logitech-objs += hid-lgff.o
18endif
19ifdef CONFIG_LOGIRUMBLEPAD2_FF
20 hid-logitech-objs += hid-lg2ff.o
21endif
22
23obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
24obj-$(CONFIG_HID_APPLE) += hid-apple.o
25obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
26obj-$(CONFIG_HID_BRIGHT) += hid-bright.o
27obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
28obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
29obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
30obj-$(CONFIG_HID_DELL) += hid-dell.o
31obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
32obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
33obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
34obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
35obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
36obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
37obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
38obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
39obj-$(CONFIG_HID_SONY) += hid-sony.o
40obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
41obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o
42obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o
43
11obj-$(CONFIG_USB_HID) += usbhid/ 44obj-$(CONFIG_USB_HID) += usbhid/
12obj-$(CONFIG_USB_MOUSE) += usbhid/ 45obj-$(CONFIG_USB_MOUSE) += usbhid/
13obj-$(CONFIG_USB_KBD) += usbhid/ 46obj-$(CONFIG_USB_KBD) += usbhid/
diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c
new file mode 100644
index 000000000000..ebca00e6c103
--- /dev/null
+++ b/drivers/hid/hid-a4tech.c
@@ -0,0 +1,162 @@
1/*
2 * HID driver for some a4tech "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/input.h>
21#include <linux/hid.h>
22#include <linux/module.h>
23
24#include "hid-ids.h"
25
26#define A4_2WHEEL_MOUSE_HACK_7 0x01
27#define A4_2WHEEL_MOUSE_HACK_B8 0x02
28
29struct a4tech_sc {
30 unsigned long quirks;
31 unsigned int hw_wheel;
32 __s32 delayed_value;
33};
34
35static int a4_input_mapped(struct hid_device *hdev, struct hid_input *hi,
36 struct hid_field *field, struct hid_usage *usage,
37 unsigned long **bit, int *max)
38{
39 struct a4tech_sc *a4 = hid_get_drvdata(hdev);
40
41 if (usage->type == EV_REL && usage->code == REL_WHEEL)
42 set_bit(REL_HWHEEL, *bit);
43
44 if ((a4->quirks & A4_2WHEEL_MOUSE_HACK_7) && usage->hid == 0x00090007)
45 return -1;
46
47 return 0;
48}
49
50static int a4_event(struct hid_device *hdev, struct hid_field *field,
51 struct hid_usage *usage, __s32 value)
52{
53 struct a4tech_sc *a4 = hid_get_drvdata(hdev);
54 struct input_dev *input;
55
56 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
57 !usage->type)
58 return 0;
59
60 input = field->hidinput->input;
61
62 if (a4->quirks & A4_2WHEEL_MOUSE_HACK_B8) {
63 if (usage->type == EV_REL && usage->code == REL_WHEEL) {
64 a4->delayed_value = value;
65 return 1;
66 }
67
68 if (usage->hid == 0x000100b8) {
69 input_event(input, EV_REL, value ? REL_HWHEEL :
70 REL_WHEEL, a4->delayed_value);
71 return 1;
72 }
73 }
74
75 if ((a4->quirks & A4_2WHEEL_MOUSE_HACK_7) && usage->hid == 0x00090007) {
76 a4->hw_wheel = !!value;
77 return 1;
78 }
79
80 if (usage->code == REL_WHEEL && a4->hw_wheel) {
81 input_event(input, usage->type, REL_HWHEEL, value);
82 return 1;
83 }
84
85 return 0;
86}
87
88static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id)
89{
90 struct a4tech_sc *a4;
91 int ret;
92
93 a4 = kzalloc(sizeof(*a4), GFP_KERNEL);
94 if (a4 == NULL) {
95 dev_err(&hdev->dev, "can't alloc device descriptor\n");
96 ret = -ENOMEM;
97 goto err_free;
98 }
99
100 a4->quirks = id->driver_data;
101
102 hid_set_drvdata(hdev, a4);
103
104 ret = hid_parse(hdev);
105 if (ret) {
106 dev_err(&hdev->dev, "parse failed\n");
107 goto err_free;
108 }
109
110 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
111 if (ret) {
112 dev_err(&hdev->dev, "hw start failed\n");
113 goto err_free;
114 }
115
116 return 0;
117err_free:
118 kfree(a4);
119 return ret;
120}
121
122static void a4_remove(struct hid_device *hdev)
123{
124 struct a4tech_sc *a4 = hid_get_drvdata(hdev);
125
126 hid_hw_stop(hdev);
127 kfree(a4);
128}
129
130static const struct hid_device_id a4_devices[] = {
131 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU),
132 .driver_data = A4_2WHEEL_MOUSE_HACK_7 },
133 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D),
134 .driver_data = A4_2WHEEL_MOUSE_HACK_B8 },
135 { }
136};
137MODULE_DEVICE_TABLE(hid, a4_devices);
138
139static struct hid_driver a4_driver = {
140 .name = "a4tech",
141 .id_table = a4_devices,
142 .input_mapped = a4_input_mapped,
143 .event = a4_event,
144 .probe = a4_probe,
145 .remove = a4_remove,
146};
147
148static int a4_init(void)
149{
150 return hid_register_driver(&a4_driver);
151}
152
153static void a4_exit(void)
154{
155 hid_unregister_driver(&a4_driver);
156}
157
158module_init(a4_init);
159module_exit(a4_exit);
160MODULE_LICENSE("GPL");
161
162HID_COMPAT_LOAD_DRIVER(a4tech);
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
new file mode 100644
index 000000000000..fd7f896b34f7
--- /dev/null
+++ b/drivers/hid/hid-apple.c
@@ -0,0 +1,484 @@
1/*
2 * USB HID quirks support for Linux
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 <jirislaby@gmail.com>
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#include <linux/usb.h>
23
24#include "hid-ids.h"
25
26#define APPLE_RDESC_JIS 0x0001
27#define APPLE_IGNORE_MOUSE 0x0002
28#define APPLE_HAS_FN 0x0004
29#define APPLE_HIDDEV 0x0008
30#define APPLE_ISO_KEYBOARD 0x0010
31#define APPLE_MIGHTYMOUSE 0x0020
32#define APPLE_INVERT_HWHEEL 0x0040
33#define APPLE_IGNORE_HIDINPUT 0x0080
34#define APPLE_NUMLOCK_EMULATION 0x0100
35
36#define APPLE_FLAG_FKEY 0x01
37
38static unsigned int fnmode = 1;
39module_param(fnmode, uint, 0644);
40MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
41 "[1] = fkeyslast, 2 = fkeysfirst)");
42
43struct apple_sc {
44 unsigned long quirks;
45 unsigned int fn_on;
46 DECLARE_BITMAP(pressed_fn, KEY_CNT);
47 DECLARE_BITMAP(pressed_numlock, KEY_CNT);
48};
49
50struct apple_key_translation {
51 u16 from;
52 u16 to;
53 u8 flags;
54};
55
56static struct apple_key_translation apple_fn_keys[] = {
57 { KEY_BACKSPACE, KEY_DELETE },
58 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
59 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
60 { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Exposé */
61 { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */
62 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
63 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
64 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
65 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
66 { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
67 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
68 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
69 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
70 { KEY_UP, KEY_PAGEUP },
71 { KEY_DOWN, KEY_PAGEDOWN },
72 { KEY_LEFT, KEY_HOME },
73 { KEY_RIGHT, KEY_END },
74 { }
75};
76
77static struct apple_key_translation powerbook_fn_keys[] = {
78 { KEY_BACKSPACE, KEY_DELETE },
79 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
80 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
81 { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
82 { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
83 { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
84 { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
85 { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
86 { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
87 { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
88 { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
89 { KEY_UP, KEY_PAGEUP },
90 { KEY_DOWN, KEY_PAGEDOWN },
91 { KEY_LEFT, KEY_HOME },
92 { KEY_RIGHT, KEY_END },
93 { }
94};
95
96static struct apple_key_translation powerbook_numlock_keys[] = {
97 { KEY_J, KEY_KP1 },
98 { KEY_K, KEY_KP2 },
99 { KEY_L, KEY_KP3 },
100 { KEY_U, KEY_KP4 },
101 { KEY_I, KEY_KP5 },
102 { KEY_O, KEY_KP6 },
103 { KEY_7, KEY_KP7 },
104 { KEY_8, KEY_KP8 },
105 { KEY_9, KEY_KP9 },
106 { KEY_M, KEY_KP0 },
107 { KEY_DOT, KEY_KPDOT },
108 { KEY_SLASH, KEY_KPPLUS },
109 { KEY_SEMICOLON, KEY_KPMINUS },
110 { KEY_P, KEY_KPASTERISK },
111 { KEY_MINUS, KEY_KPEQUAL },
112 { KEY_0, KEY_KPSLASH },
113 { KEY_F6, KEY_NUMLOCK },
114 { KEY_KPENTER, KEY_KPENTER },
115 { KEY_BACKSPACE, KEY_BACKSPACE },
116 { }
117};
118
119static struct apple_key_translation apple_iso_keyboard[] = {
120 { KEY_GRAVE, KEY_102ND },
121 { KEY_102ND, KEY_GRAVE },
122 { }
123};
124
125static struct apple_key_translation *apple_find_translation(
126 struct apple_key_translation *table, u16 from)
127{
128 struct apple_key_translation *trans;
129
130 /* Look for the translation */
131 for (trans = table; trans->from; trans++)
132 if (trans->from == from)
133 return trans;
134
135 return NULL;
136}
137
138static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
139 struct hid_usage *usage, __s32 value)
140{
141 struct apple_sc *asc = hid_get_drvdata(hid);
142 struct apple_key_translation *trans;
143
144 if (usage->code == KEY_FN) {
145 asc->fn_on = !!value;
146 input_event(input, usage->type, usage->code, value);
147 return 1;
148 }
149
150 if (fnmode) {
151 int do_translate;
152
153 trans = apple_find_translation((hid->product < 0x220 ||
154 hid->product >= 0x300) ?
155 powerbook_fn_keys : apple_fn_keys,
156 usage->code);
157 if (trans) {
158 if (test_bit(usage->code, asc->pressed_fn))
159 do_translate = 1;
160 else if (trans->flags & APPLE_FLAG_FKEY)
161 do_translate = (fnmode == 2 && asc->fn_on) ||
162 (fnmode == 1 && !asc->fn_on);
163 else
164 do_translate = asc->fn_on;
165
166 if (do_translate) {
167 if (value)
168 set_bit(usage->code, asc->pressed_fn);
169 else
170 clear_bit(usage->code, asc->pressed_fn);
171
172 input_event(input, usage->type, trans->to,
173 value);
174
175 return 1;
176 }
177 }
178
179 if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
180 (test_bit(usage->code, asc->pressed_numlock) ||
181 test_bit(LED_NUML, input->led))) {
182 trans = apple_find_translation(powerbook_numlock_keys,
183 usage->code);
184
185 if (trans) {
186 if (value)
187 set_bit(usage->code,
188 asc->pressed_numlock);
189 else
190 clear_bit(usage->code,
191 asc->pressed_numlock);
192
193 input_event(input, usage->type, trans->to,
194 value);
195 }
196
197 return 1;
198 }
199 }
200
201 if (asc->quirks & APPLE_ISO_KEYBOARD) {
202 trans = apple_find_translation(apple_iso_keyboard, usage->code);
203 if (trans) {
204 input_event(input, usage->type, trans->to, value);
205 return 1;
206 }
207 }
208
209 return 0;
210}
211
212static int apple_event(struct hid_device *hdev, struct hid_field *field,
213 struct hid_usage *usage, __s32 value)
214{
215 struct apple_sc *asc = hid_get_drvdata(hdev);
216
217 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
218 !usage->type)
219 return 0;
220
221 if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
222 usage->code == REL_HWHEEL) {
223 input_event(field->hidinput->input, usage->type, usage->code,
224 -value);
225 return 1;
226 }
227
228 if ((asc->quirks & APPLE_HAS_FN) &&
229 hidinput_apple_event(hdev, field->hidinput->input,
230 usage, value))
231 return 1;
232
233
234 return 0;
235}
236
237/*
238 * MacBook JIS keyboard has wrong logical maximum
239 */
240static void apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
241 unsigned int rsize)
242{
243 struct apple_sc *asc = hid_get_drvdata(hdev);
244
245 if ((asc->quirks & APPLE_RDESC_JIS) && rsize >= 60 &&
246 rdesc[53] == 0x65 && rdesc[59] == 0x65) {
247 dev_info(&hdev->dev, "fixing up MacBook JIS keyboard report "
248 "descriptor\n");
249 rdesc[53] = rdesc[59] = 0xe7;
250 }
251}
252
253static void apple_setup_input(struct input_dev *input)
254{
255 struct apple_key_translation *trans;
256
257 set_bit(KEY_NUMLOCK, input->keybit);
258
259 /* Enable all needed keys */
260 for (trans = apple_fn_keys; trans->from; trans++)
261 set_bit(trans->to, input->keybit);
262
263 for (trans = powerbook_fn_keys; trans->from; trans++)
264 set_bit(trans->to, input->keybit);
265
266 for (trans = powerbook_numlock_keys; trans->from; trans++)
267 set_bit(trans->to, input->keybit);
268
269 for (trans = apple_iso_keyboard; trans->from; trans++)
270 set_bit(trans->to, input->keybit);
271}
272
273static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
274 struct hid_field *field, struct hid_usage *usage,
275 unsigned long **bit, int *max)
276{
277 if (usage->hid == (HID_UP_CUSTOM | 0x0003)) {
278 /* The fn key on Apple USB keyboards */
279 set_bit(EV_REP, hi->input->evbit);
280 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
281 apple_setup_input(hi->input);
282 return 1;
283 }
284
285 /* we want the hid layer to go through standard path (set and ignore) */
286 return 0;
287}
288
289static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
290 struct hid_field *field, struct hid_usage *usage,
291 unsigned long **bit, int *max)
292{
293 struct apple_sc *asc = hid_get_drvdata(hdev);
294
295 if (asc->quirks & APPLE_MIGHTYMOUSE) {
296 if (usage->hid == HID_GD_Z)
297 hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
298 else if (usage->code == BTN_1)
299 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
300 else if (usage->code == BTN_2)
301 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
302 }
303
304 return 0;
305}
306
307static int apple_probe(struct hid_device *hdev,
308 const struct hid_device_id *id)
309{
310 unsigned long quirks = id->driver_data;
311 struct apple_sc *asc;
312 unsigned int connect_mask = HID_CONNECT_DEFAULT;
313 int ret;
314
315 /* return something else or move to hid layer? device will reside
316 allocated */
317 if (id->bus == BUS_USB && (quirks & APPLE_IGNORE_MOUSE) &&
318 to_usb_interface(hdev->dev.parent)->cur_altsetting->
319 desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE)
320 return -ENODEV;
321
322 asc = kzalloc(sizeof(*asc), GFP_KERNEL);
323 if (asc == NULL) {
324 dev_err(&hdev->dev, "can't alloc apple descriptor\n");
325 return -ENOMEM;
326 }
327
328 asc->quirks = quirks;
329
330 hid_set_drvdata(hdev, asc);
331
332 ret = hid_parse(hdev);
333 if (ret) {
334 dev_err(&hdev->dev, "parse failed\n");
335 goto err_free;
336 }
337
338 if (quirks & APPLE_HIDDEV)
339 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
340 if (quirks & APPLE_IGNORE_HIDINPUT)
341 connect_mask &= ~HID_CONNECT_HIDINPUT;
342
343 ret = hid_hw_start(hdev, connect_mask);
344 if (ret) {
345 dev_err(&hdev->dev, "hw start failed\n");
346 goto err_free;
347 }
348
349 return 0;
350err_free:
351 kfree(asc);
352 return ret;
353}
354
355static void apple_remove(struct hid_device *hdev)
356{
357 hid_hw_stop(hdev);
358 kfree(hid_get_drvdata(hdev));
359}
360
361static const struct hid_device_id apple_devices[] = {
362 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL),
363 .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT },
364 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4),
365 .driver_data = APPLE_HIDDEV | APPLE_IGNORE_HIDINPUT },
366 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
367 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
368
369 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
370 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
371 APPLE_IGNORE_MOUSE },
372 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
373 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
374 APPLE_IGNORE_MOUSE },
375 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
376 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
377 APPLE_IGNORE_MOUSE },
378 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
379 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
380 APPLE_IGNORE_MOUSE | APPLE_ISO_KEYBOARD },
381 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
382 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
383 APPLE_IGNORE_MOUSE },
384 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
385 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
386 APPLE_IGNORE_MOUSE },
387 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
388 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
389 APPLE_IGNORE_MOUSE | APPLE_ISO_KEYBOARD },
390 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
391 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
392 APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS },
393 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
394 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
395 APPLE_IGNORE_MOUSE },
396 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
397 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
398 APPLE_IGNORE_MOUSE | APPLE_ISO_KEYBOARD },
399 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
400 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
401 APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS},
402 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
403 .driver_data = APPLE_HAS_FN },
404 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
405 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
406 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
407 .driver_data = APPLE_HAS_FN },
408 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
409 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
410 APPLE_IGNORE_MOUSE },
411 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
412 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
413 APPLE_IGNORE_MOUSE },
414 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
415 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
416 APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS },
417 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
418 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
419 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
420 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
421 APPLE_ISO_KEYBOARD },
422 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
423 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
424 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
425 .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE },
426 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
427 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD |
428 APPLE_IGNORE_MOUSE },
429 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
430 .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS },
431 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
432 .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE },
433 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
434 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD |
435 APPLE_IGNORE_MOUSE },
436 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
437 .driver_data = APPLE_HAS_FN | APPLE_IGNORE_MOUSE | APPLE_RDESC_JIS },
438 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
439 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
440 APPLE_IGNORE_MOUSE },
441 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
442 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
443 APPLE_IGNORE_MOUSE },
444
445 /* Apple wireless Mighty Mouse */
446 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c),
447 .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
448
449 { }
450};
451MODULE_DEVICE_TABLE(hid, apple_devices);
452
453static struct hid_driver apple_driver = {
454 .name = "apple",
455 .id_table = apple_devices,
456 .report_fixup = apple_report_fixup,
457 .probe = apple_probe,
458 .remove = apple_remove,
459 .event = apple_event,
460 .input_mapping = apple_input_mapping,
461 .input_mapped = apple_input_mapped,
462};
463
464static int apple_init(void)
465{
466 int ret;
467
468 ret = hid_register_driver(&apple_driver);
469 if (ret)
470 printk(KERN_ERR "can't register apple driver\n");
471
472 return ret;
473}
474
475static void apple_exit(void)
476{
477 hid_unregister_driver(&apple_driver);
478}
479
480module_init(apple_init);
481module_exit(apple_exit);
482MODULE_LICENSE("GPL");
483
484HID_COMPAT_LOAD_DRIVER(apple);
diff --git a/drivers/hid/hid-belkin.c b/drivers/hid/hid-belkin.c
new file mode 100644
index 000000000000..12c8a9ba6ed6
--- /dev/null
+++ b/drivers/hid/hid-belkin.c
@@ -0,0 +1,105 @@
1/*
2 * HID driver for some belkin "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
25#define BELKIN_HIDDEV 0x01
26#define BELKIN_WKBD 0x02
27
28#define belkin_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
29 EV_KEY, (c))
30static int belkin_input_mapping(struct hid_device *hdev, struct hid_input *hi,
31 struct hid_field *field, struct hid_usage *usage,
32 unsigned long **bit, int *max)
33{
34 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
35
36 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER ||
37 !(quirks & BELKIN_WKBD))
38 return 0;
39
40 switch (usage->hid & HID_USAGE) {
41 case 0x03a: belkin_map_key_clear(KEY_SOUND); break;
42 case 0x03b: belkin_map_key_clear(KEY_CAMERA); break;
43 case 0x03c: belkin_map_key_clear(KEY_DOCUMENTS); break;
44 default:
45 return 0;
46 }
47 return 1;
48}
49
50static int belkin_probe(struct hid_device *hdev, const struct hid_device_id *id)
51{
52 unsigned long quirks = id->driver_data;
53 int ret;
54
55 hid_set_drvdata(hdev, (void *)quirks);
56
57 ret = hid_parse(hdev);
58 if (ret) {
59 dev_err(&hdev->dev, "parse failed\n");
60 goto err_free;
61 }
62
63 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT |
64 ((quirks & BELKIN_HIDDEV) ? HID_CONNECT_HIDDEV_FORCE : 0));
65 if (ret) {
66 dev_err(&hdev->dev, "hw start failed\n");
67 goto err_free;
68 }
69
70 return 0;
71err_free:
72 return ret;
73}
74
75static const struct hid_device_id belkin_devices[] = {
76 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM),
77 .driver_data = BELKIN_HIDDEV },
78 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD),
79 .driver_data = BELKIN_WKBD },
80 { }
81};
82MODULE_DEVICE_TABLE(hid, belkin_devices);
83
84static struct hid_driver belkin_driver = {
85 .name = "belkin",
86 .id_table = belkin_devices,
87 .input_mapping = belkin_input_mapping,
88 .probe = belkin_probe,
89};
90
91static int belkin_init(void)
92{
93 return hid_register_driver(&belkin_driver);
94}
95
96static void belkin_exit(void)
97{
98 hid_unregister_driver(&belkin_driver);
99}
100
101module_init(belkin_init);
102module_exit(belkin_exit);
103MODULE_LICENSE("GPL");
104
105HID_COMPAT_LOAD_DRIVER(belkin);
diff --git a/drivers/hid/hid-bright.c b/drivers/hid/hid-bright.c
new file mode 100644
index 000000000000..38517a117dfd
--- /dev/null
+++ b/drivers/hid/hid-bright.c
@@ -0,0 +1,71 @@
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-cherry.c b/drivers/hid/hid-cherry.c
new file mode 100644
index 000000000000..b833b9769aba
--- /dev/null
+++ b/drivers/hid/hid-cherry.c
@@ -0,0 +1,87 @@
1/*
2 * HID driver for some cherry "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
25/*
26 * Cherry Cymotion keyboard have an invalid HID report descriptor,
27 * that needs fixing before we can parse it.
28 */
29static void ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
30 unsigned int rsize)
31{
32 if (rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
33 dev_info(&hdev->dev, "fixing up Cherry Cymotion report "
34 "descriptor\n");
35 rdesc[11] = rdesc[16] = 0xff;
36 rdesc[12] = rdesc[17] = 0x03;
37 }
38}
39
40#define ch_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
41 EV_KEY, (c))
42static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
43 struct hid_field *field, struct hid_usage *usage,
44 unsigned long **bit, int *max)
45{
46 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
47 return 0;
48
49 switch (usage->hid & HID_USAGE) {
50 case 0x301: ch_map_key_clear(KEY_PROG1); break;
51 case 0x302: ch_map_key_clear(KEY_PROG2); break;
52 case 0x303: ch_map_key_clear(KEY_PROG3); break;
53 default:
54 return 0;
55 }
56
57 return 1;
58}
59
60static const struct hid_device_id ch_devices[] = {
61 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
62 { }
63};
64MODULE_DEVICE_TABLE(hid, ch_devices);
65
66static struct hid_driver ch_driver = {
67 .name = "cherry",
68 .id_table = ch_devices,
69 .report_fixup = ch_report_fixup,
70 .input_mapping = ch_input_mapping,
71};
72
73static int ch_init(void)
74{
75 return hid_register_driver(&ch_driver);
76}
77
78static void ch_exit(void)
79{
80 hid_unregister_driver(&ch_driver);
81}
82
83module_init(ch_init);
84module_exit(ch_exit);
85MODULE_LICENSE("GPL");
86
87HID_COMPAT_LOAD_DRIVER(cherry);
diff --git a/drivers/hid/hid-chicony.c b/drivers/hid/hid-chicony.c
new file mode 100644
index 000000000000..a54d4096e0f7
--- /dev/null
+++ b/drivers/hid/hid-chicony.c
@@ -0,0 +1,80 @@
1/*
2 * HID driver for some chicony "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/input.h>
21#include <linux/hid.h>
22#include <linux/module.h>
23
24#include "hid-ids.h"
25
26#define ch_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
27 EV_KEY, (c))
28static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
29 struct hid_field *field, struct hid_usage *usage,
30 unsigned long **bit, int *max)
31{
32 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
33 return 0;
34
35 set_bit(EV_REP, hi->input->evbit);
36 switch (usage->hid & HID_USAGE) {
37 case 0xff01: ch_map_key_clear(BTN_1); break;
38 case 0xff02: ch_map_key_clear(BTN_2); break;
39 case 0xff03: ch_map_key_clear(BTN_3); break;
40 case 0xff04: ch_map_key_clear(BTN_4); break;
41 case 0xff05: ch_map_key_clear(BTN_5); break;
42 case 0xff06: ch_map_key_clear(BTN_6); break;
43 case 0xff07: ch_map_key_clear(BTN_7); break;
44 case 0xff08: ch_map_key_clear(BTN_8); break;
45 case 0xff09: ch_map_key_clear(BTN_9); break;
46 case 0xff0a: ch_map_key_clear(BTN_A); break;
47 case 0xff0b: ch_map_key_clear(BTN_B); break;
48 default:
49 return 0;
50 }
51 return 1;
52}
53
54static const struct hid_device_id ch_devices[] = {
55 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
56 { }
57};
58MODULE_DEVICE_TABLE(hid, ch_devices);
59
60static struct hid_driver ch_driver = {
61 .name = "chicony",
62 .id_table = ch_devices,
63 .input_mapping = ch_input_mapping,
64};
65
66static int ch_init(void)
67{
68 return hid_register_driver(&ch_driver);
69}
70
71static void ch_exit(void)
72{
73 hid_unregister_driver(&ch_driver);
74}
75
76module_init(ch_init);
77module_exit(ch_exit);
78MODULE_LICENSE("GPL");
79
80HID_COMPAT_LOAD_DRIVER(chicony);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 426ac5add585..8a7d9dbb4d07 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -33,6 +33,8 @@
33#include <linux/hid-debug.h> 33#include <linux/hid-debug.h>
34#include <linux/hidraw.h> 34#include <linux/hidraw.h>
35 35
36#include "hid-ids.h"
37
36/* 38/*
37 * Version Information 39 * Version Information
38 */ 40 */
@@ -268,9 +270,9 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
268static u32 item_udata(struct hid_item *item) 270static u32 item_udata(struct hid_item *item)
269{ 271{
270 switch (item->size) { 272 switch (item->size) {
271 case 1: return item->data.u8; 273 case 1: return item->data.u8;
272 case 2: return item->data.u16; 274 case 2: return item->data.u16;
273 case 4: return item->data.u32; 275 case 4: return item->data.u32;
274 } 276 }
275 return 0; 277 return 0;
276} 278}
@@ -278,9 +280,9 @@ static u32 item_udata(struct hid_item *item)
278static s32 item_sdata(struct hid_item *item) 280static s32 item_sdata(struct hid_item *item)
279{ 281{
280 switch (item->size) { 282 switch (item->size) {
281 case 1: return item->data.s8; 283 case 1: return item->data.s8;
282 case 2: return item->data.s16; 284 case 2: return item->data.s16;
283 case 4: return item->data.s32; 285 case 4: return item->data.s32;
284 } 286 }
285 return 0; 287 return 0;
286} 288}
@@ -292,87 +294,91 @@ static s32 item_sdata(struct hid_item *item)
292static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 294static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
293{ 295{
294 switch (item->tag) { 296 switch (item->tag) {
297 case HID_GLOBAL_ITEM_TAG_PUSH:
295 298
296 case HID_GLOBAL_ITEM_TAG_PUSH: 299 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
297 300 dbg_hid("global enviroment stack overflow\n");
298 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 301 return -1;
299 dbg_hid("global enviroment stack overflow\n"); 302 }
300 return -1;
301 }
302 303
303 memcpy(parser->global_stack + parser->global_stack_ptr++, 304 memcpy(parser->global_stack + parser->global_stack_ptr++,
304 &parser->global, sizeof(struct hid_global)); 305 &parser->global, sizeof(struct hid_global));
305 return 0; 306 return 0;
306 307
307 case HID_GLOBAL_ITEM_TAG_POP: 308 case HID_GLOBAL_ITEM_TAG_POP:
308 309
309 if (!parser->global_stack_ptr) { 310 if (!parser->global_stack_ptr) {
310 dbg_hid("global enviroment stack underflow\n"); 311 dbg_hid("global enviroment stack underflow\n");
311 return -1; 312 return -1;
312 } 313 }
313
314 memcpy(&parser->global, parser->global_stack + --parser->global_stack_ptr,
315 sizeof(struct hid_global));
316 return 0;
317 314
318 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 315 memcpy(&parser->global, parser->global_stack +
319 parser->global.usage_page = item_udata(item); 316 --parser->global_stack_ptr, sizeof(struct hid_global));
320 return 0; 317 return 0;
321 318
322 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 319 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
323 parser->global.logical_minimum = item_sdata(item); 320 parser->global.usage_page = item_udata(item);
324 return 0; 321 return 0;
325 322
326 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 323 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
327 if (parser->global.logical_minimum < 0) 324 parser->global.logical_minimum = item_sdata(item);
328 parser->global.logical_maximum = item_sdata(item); 325 return 0;
329 else
330 parser->global.logical_maximum = item_udata(item);
331 return 0;
332 326
333 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 327 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
334 parser->global.physical_minimum = item_sdata(item); 328 if (parser->global.logical_minimum < 0)
335 return 0; 329 parser->global.logical_maximum = item_sdata(item);
330 else
331 parser->global.logical_maximum = item_udata(item);
332 return 0;
336 333
337 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 334 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
338 if (parser->global.physical_minimum < 0) 335 parser->global.physical_minimum = item_sdata(item);
339 parser->global.physical_maximum = item_sdata(item); 336 return 0;
340 else
341 parser->global.physical_maximum = item_udata(item);
342 return 0;
343 337
344 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 338 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
345 parser->global.unit_exponent = item_sdata(item); 339 if (parser->global.physical_minimum < 0)
346 return 0; 340 parser->global.physical_maximum = item_sdata(item);
341 else
342 parser->global.physical_maximum = item_udata(item);
343 return 0;
347 344
348 case HID_GLOBAL_ITEM_TAG_UNIT: 345 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
349 parser->global.unit = item_udata(item); 346 parser->global.unit_exponent = item_sdata(item);
350 return 0; 347 return 0;
351 348
352 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 349 case HID_GLOBAL_ITEM_TAG_UNIT:
353 if ((parser->global.report_size = item_udata(item)) > 32) { 350 parser->global.unit = item_udata(item);
354 dbg_hid("invalid report_size %d\n", parser->global.report_size); 351 return 0;
355 return -1;
356 }
357 return 0;
358 352
359 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 353 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
360 if ((parser->global.report_count = item_udata(item)) > HID_MAX_USAGES) { 354 parser->global.report_size = item_udata(item);
361 dbg_hid("invalid report_count %d\n", parser->global.report_count); 355 if (parser->global.report_size > 32) {
362 return -1; 356 dbg_hid("invalid report_size %d\n",
363 } 357 parser->global.report_size);
364 return 0; 358 return -1;
359 }
360 return 0;
365 361
366 case HID_GLOBAL_ITEM_TAG_REPORT_ID: 362 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
367 if ((parser->global.report_id = item_udata(item)) == 0) { 363 parser->global.report_count = item_udata(item);
368 dbg_hid("report_id 0 is invalid\n"); 364 if (parser->global.report_count > HID_MAX_USAGES) {
369 return -1; 365 dbg_hid("invalid report_count %d\n",
370 } 366 parser->global.report_count);
371 return 0; 367 return -1;
368 }
369 return 0;
372 370
373 default: 371 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
374 dbg_hid("unknown global tag 0x%x\n", item->tag); 372 parser->global.report_id = item_udata(item);
373 if (parser->global.report_id == 0) {
374 dbg_hid("report_id 0 is invalid\n");
375 return -1; 375 return -1;
376 }
377 return 0;
378
379 default:
380 dbg_hid("unknown global tag 0x%x\n", item->tag);
381 return -1;
376 } 382 }
377} 383}
378 384
@@ -393,77 +399,76 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
393 data = item_udata(item); 399 data = item_udata(item);
394 400
395 switch (item->tag) { 401 switch (item->tag) {
396 402 case HID_LOCAL_ITEM_TAG_DELIMITER:
397 case HID_LOCAL_ITEM_TAG_DELIMITER: 403
398 404 if (data) {
399 if (data) { 405 /*
400 /* 406 * We treat items before the first delimiter
401 * We treat items before the first delimiter 407 * as global to all usage sets (branch 0).
402 * as global to all usage sets (branch 0). 408 * In the moment we process only these global
403 * In the moment we process only these global 409 * items and the first delimiter set.
404 * items and the first delimiter set. 410 */
405 */ 411 if (parser->local.delimiter_depth != 0) {
406 if (parser->local.delimiter_depth != 0) { 412 dbg_hid("nested delimiters\n");
407 dbg_hid("nested delimiters\n"); 413 return -1;
408 return -1;
409 }
410 parser->local.delimiter_depth++;
411 parser->local.delimiter_branch++;
412 } else {
413 if (parser->local.delimiter_depth < 1) {
414 dbg_hid("bogus close delimiter\n");
415 return -1;
416 }
417 parser->local.delimiter_depth--;
418 } 414 }
419 return 1; 415 parser->local.delimiter_depth++;
420 416 parser->local.delimiter_branch++;
421 case HID_LOCAL_ITEM_TAG_USAGE: 417 } else {
422 418 if (parser->local.delimiter_depth < 1) {
423 if (parser->local.delimiter_branch > 1) { 419 dbg_hid("bogus close delimiter\n");
424 dbg_hid("alternative usage ignored\n"); 420 return -1;
425 return 0;
426 } 421 }
422 parser->local.delimiter_depth--;
423 }
424 return 1;
427 425
428 if (item->size <= 2) 426 case HID_LOCAL_ITEM_TAG_USAGE:
429 data = (parser->global.usage_page << 16) + data;
430 427
431 return hid_add_usage(parser, data); 428 if (parser->local.delimiter_branch > 1) {
429 dbg_hid("alternative usage ignored\n");
430 return 0;
431 }
432 432
433 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 433 if (item->size <= 2)
434 data = (parser->global.usage_page << 16) + data;
434 435
435 if (parser->local.delimiter_branch > 1) { 436 return hid_add_usage(parser, data);
436 dbg_hid("alternative usage ignored\n");
437 return 0;
438 }
439 437
440 if (item->size <= 2) 438 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
441 data = (parser->global.usage_page << 16) + data;
442 439
443 parser->local.usage_minimum = data; 440 if (parser->local.delimiter_branch > 1) {
441 dbg_hid("alternative usage ignored\n");
444 return 0; 442 return 0;
443 }
445 444
446 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 445 if (item->size <= 2)
446 data = (parser->global.usage_page << 16) + data;
447 447
448 if (parser->local.delimiter_branch > 1) { 448 parser->local.usage_minimum = data;
449 dbg_hid("alternative usage ignored\n"); 449 return 0;
450 return 0;
451 }
452 450
453 if (item->size <= 2) 451 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
454 data = (parser->global.usage_page << 16) + data;
455 452
456 for (n = parser->local.usage_minimum; n <= data; n++) 453 if (parser->local.delimiter_branch > 1) {
457 if (hid_add_usage(parser, n)) { 454 dbg_hid("alternative usage ignored\n");
458 dbg_hid("hid_add_usage failed\n");
459 return -1;
460 }
461 return 0; 455 return 0;
456 }
462 457
463 default: 458 if (item->size <= 2)
459 data = (parser->global.usage_page << 16) + data;
464 460
465 dbg_hid("unknown local item tag 0x%x\n", item->tag); 461 for (n = parser->local.usage_minimum; n <= data; n++)
466 return 0; 462 if (hid_add_usage(parser, n)) {
463 dbg_hid("hid_add_usage failed\n");
464 return -1;
465 }
466 return 0;
467
468 default:
469
470 dbg_hid("unknown local item tag 0x%x\n", item->tag);
471 return 0;
467 } 472 }
468 return 0; 473 return 0;
469} 474}
@@ -480,24 +485,24 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
480 data = item_udata(item); 485 data = item_udata(item);
481 486
482 switch (item->tag) { 487 switch (item->tag) {
483 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 488 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
484 ret = open_collection(parser, data & 0xff); 489 ret = open_collection(parser, data & 0xff);
485 break; 490 break;
486 case HID_MAIN_ITEM_TAG_END_COLLECTION: 491 case HID_MAIN_ITEM_TAG_END_COLLECTION:
487 ret = close_collection(parser); 492 ret = close_collection(parser);
488 break; 493 break;
489 case HID_MAIN_ITEM_TAG_INPUT: 494 case HID_MAIN_ITEM_TAG_INPUT:
490 ret = hid_add_field(parser, HID_INPUT_REPORT, data); 495 ret = hid_add_field(parser, HID_INPUT_REPORT, data);
491 break; 496 break;
492 case HID_MAIN_ITEM_TAG_OUTPUT: 497 case HID_MAIN_ITEM_TAG_OUTPUT:
493 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 498 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
494 break; 499 break;
495 case HID_MAIN_ITEM_TAG_FEATURE: 500 case HID_MAIN_ITEM_TAG_FEATURE:
496 ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 501 ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
497 break; 502 break;
498 default: 503 default:
499 dbg_hid("unknown main item tag 0x%x\n", item->tag); 504 dbg_hid("unknown main item tag 0x%x\n", item->tag);
500 ret = 0; 505 ret = 0;
501 } 506 }
502 507
503 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 508 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */
@@ -534,9 +539,10 @@ static void hid_free_report(struct hid_report *report)
534 * Free a device structure, all reports, and all fields. 539 * Free a device structure, all reports, and all fields.
535 */ 540 */
536 541
537void hid_free_device(struct hid_device *device) 542static void hid_device_release(struct device *dev)
538{ 543{
539 unsigned i,j; 544 struct hid_device *device = container_of(dev, struct hid_device, dev);
545 unsigned i, j;
540 546
541 for (i = 0; i < HID_REPORT_TYPES; i++) { 547 for (i = 0; i < HID_REPORT_TYPES; i++) {
542 struct hid_report_enum *report_enum = device->report_enum + i; 548 struct hid_report_enum *report_enum = device->report_enum + i;
@@ -552,7 +558,6 @@ void hid_free_device(struct hid_device *device)
552 kfree(device->collection); 558 kfree(device->collection);
553 kfree(device); 559 kfree(device);
554} 560}
555EXPORT_SYMBOL_GPL(hid_free_device);
556 561
557/* 562/*
558 * Fetch a report description item from the data stream. We support long 563 * Fetch a report description item from the data stream. We support long
@@ -593,47 +598,52 @@ static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
593 item->size = b & 3; 598 item->size = b & 3;
594 599
595 switch (item->size) { 600 switch (item->size) {
601 case 0:
602 return start;
596 603
597 case 0: 604 case 1:
598 return start; 605 if ((end - start) < 1)
599 606 return NULL;
600 case 1: 607 item->data.u8 = *start++;
601 if ((end - start) < 1) 608 return start;
602 return NULL;
603 item->data.u8 = *start++;
604 return start;
605 609
606 case 2: 610 case 2:
607 if ((end - start) < 2) 611 if ((end - start) < 2)
608 return NULL; 612 return NULL;
609 item->data.u16 = get_unaligned_le16(start); 613 item->data.u16 = get_unaligned_le16(start);
610 start = (__u8 *)((__le16 *)start + 1); 614 start = (__u8 *)((__le16 *)start + 1);
611 return start; 615 return start;
612 616
613 case 3: 617 case 3:
614 item->size++; 618 item->size++;
615 if ((end - start) < 4) 619 if ((end - start) < 4)
616 return NULL; 620 return NULL;
617 item->data.u32 = get_unaligned_le32(start); 621 item->data.u32 = get_unaligned_le32(start);
618 start = (__u8 *)((__le32 *)start + 1); 622 start = (__u8 *)((__le32 *)start + 1);
619 return start; 623 return start;
620 } 624 }
621 625
622 return NULL; 626 return NULL;
623} 627}
624 628
625/* 629/**
630 * hid_parse_report - parse device report
631 *
632 * @device: hid device
633 * @start: report start
634 * @size: report size
635 *
626 * Parse a report description into a hid_device structure. Reports are 636 * Parse a report description into a hid_device structure. Reports are
627 * enumerated, fields are attached to these reports. 637 * enumerated, fields are attached to these reports.
638 * 0 returned on success, otherwise nonzero error value.
628 */ 639 */
629 640int hid_parse_report(struct hid_device *device, __u8 *start,
630struct hid_device *hid_parse_report(__u8 *start, unsigned size) 641 unsigned size)
631{ 642{
632 struct hid_device *device;
633 struct hid_parser *parser; 643 struct hid_parser *parser;
634 struct hid_item item; 644 struct hid_item item;
635 __u8 *end; 645 __u8 *end;
636 unsigned i; 646 int ret;
637 static int (*dispatch_type[])(struct hid_parser *parser, 647 static int (*dispatch_type[])(struct hid_parser *parser,
638 struct hid_item *item) = { 648 struct hid_item *item) = {
639 hid_parser_main, 649 hid_parser_main,
@@ -642,76 +652,57 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
642 hid_parser_reserved 652 hid_parser_reserved
643 }; 653 };
644 654
645 if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL))) 655 if (device->driver->report_fixup)
646 return NULL; 656 device->driver->report_fixup(device, start, size);
647 657
648 if (!(device->collection = kzalloc(sizeof(struct hid_collection) * 658 device->rdesc = kmalloc(size, GFP_KERNEL);
649 HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) { 659 if (device->rdesc == NULL)
650 kfree(device); 660 return -ENOMEM;
651 return NULL;
652 }
653 device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
654
655 for (i = 0; i < HID_REPORT_TYPES; i++)
656 INIT_LIST_HEAD(&device->report_enum[i].report_list);
657
658 if (!(device->rdesc = kmalloc(size, GFP_KERNEL))) {
659 kfree(device->collection);
660 kfree(device);
661 return NULL;
662 }
663 memcpy(device->rdesc, start, size); 661 memcpy(device->rdesc, start, size);
664 device->rsize = size; 662 device->rsize = size;
665 663
666 if (!(parser = vmalloc(sizeof(struct hid_parser)))) { 664 parser = vmalloc(sizeof(struct hid_parser));
667 kfree(device->rdesc); 665 if (!parser) {
668 kfree(device->collection); 666 ret = -ENOMEM;
669 kfree(device); 667 goto err;
670 return NULL;
671 } 668 }
669
672 memset(parser, 0, sizeof(struct hid_parser)); 670 memset(parser, 0, sizeof(struct hid_parser));
673 parser->device = device; 671 parser->device = device;
674 672
675 end = start + size; 673 end = start + size;
674 ret = -EINVAL;
676 while ((start = fetch_item(start, end, &item)) != NULL) { 675 while ((start = fetch_item(start, end, &item)) != NULL) {
677 676
678 if (item.format != HID_ITEM_FORMAT_SHORT) { 677 if (item.format != HID_ITEM_FORMAT_SHORT) {
679 dbg_hid("unexpected long global item\n"); 678 dbg_hid("unexpected long global item\n");
680 hid_free_device(device); 679 goto err;
681 vfree(parser);
682 return NULL;
683 } 680 }
684 681
685 if (dispatch_type[item.type](parser, &item)) { 682 if (dispatch_type[item.type](parser, &item)) {
686 dbg_hid("item %u %u %u %u parsing failed\n", 683 dbg_hid("item %u %u %u %u parsing failed\n",
687 item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag); 684 item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag);
688 hid_free_device(device); 685 goto err;
689 vfree(parser);
690 return NULL;
691 } 686 }
692 687
693 if (start == end) { 688 if (start == end) {
694 if (parser->collection_stack_ptr) { 689 if (parser->collection_stack_ptr) {
695 dbg_hid("unbalanced collection at end of report description\n"); 690 dbg_hid("unbalanced collection at end of report description\n");
696 hid_free_device(device); 691 goto err;
697 vfree(parser);
698 return NULL;
699 } 692 }
700 if (parser->local.delimiter_depth) { 693 if (parser->local.delimiter_depth) {
701 dbg_hid("unbalanced delimiter at end of report description\n"); 694 dbg_hid("unbalanced delimiter at end of report description\n");
702 hid_free_device(device); 695 goto err;
703 vfree(parser);
704 return NULL;
705 } 696 }
706 vfree(parser); 697 vfree(parser);
707 return device; 698 return 0;
708 } 699 }
709 } 700 }
710 701
711 dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); 702 dbg_hid("item fetching failed at offset %d\n", (int)(end - start));
712 hid_free_device(device); 703err:
713 vfree(parser); 704 vfree(parser);
714 return NULL; 705 return ret;
715} 706}
716EXPORT_SYMBOL_GPL(hid_parse_report); 707EXPORT_SYMBOL_GPL(hid_parse_report);
717 708
@@ -724,9 +715,9 @@ EXPORT_SYMBOL_GPL(hid_parse_report);
724static s32 snto32(__u32 value, unsigned n) 715static s32 snto32(__u32 value, unsigned n)
725{ 716{
726 switch (n) { 717 switch (n) {
727 case 8: return ((__s8)value); 718 case 8: return ((__s8)value);
728 case 16: return ((__s16)value); 719 case 16: return ((__s16)value);
729 case 32: return ((__s32)value); 720 case 32: return ((__s32)value);
730 } 721 }
731 return value & (1 << (n - 1)) ? value | (-1 << n) : value; 722 return value & (1 << (n - 1)) ? value | (-1 << n) : value;
732} 723}
@@ -815,9 +806,73 @@ static __inline__ int search(__s32 *array, __s32 value, unsigned n)
815 return -1; 806 return -1;
816} 807}
817 808
818static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt) 809/**
810 * hid_match_report - check if driver's raw_event should be called
811 *
812 * @hid: hid device
813 * @report_type: type to match against
814 *
815 * compare hid->driver->report_table->report_type to report->type
816 */
817static int hid_match_report(struct hid_device *hid, struct hid_report *report)
818{
819 const struct hid_report_id *id = hid->driver->report_table;
820
821 if (!id) /* NULL means all */
822 return 1;
823
824 for (; id->report_type != HID_TERMINATOR; id++)
825 if (id->report_type == HID_ANY_ID ||
826 id->report_type == report->type)
827 return 1;
828 return 0;
829}
830
831/**
832 * hid_match_usage - check if driver's event should be called
833 *
834 * @hid: hid device
835 * @usage: usage to match against
836 *
837 * compare hid->driver->usage_table->usage_{type,code} to
838 * usage->usage_{type,code}
839 */
840static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage)
819{ 841{
842 const struct hid_usage_id *id = hid->driver->usage_table;
843
844 if (!id) /* NULL means all */
845 return 1;
846
847 for (; id->usage_type != HID_ANY_ID - 1; id++)
848 if ((id->usage_hid == HID_ANY_ID ||
849 id->usage_hid == usage->hid) &&
850 (id->usage_type == HID_ANY_ID ||
851 id->usage_type == usage->type) &&
852 (id->usage_code == HID_ANY_ID ||
853 id->usage_code == usage->code))
854 return 1;
855 return 0;
856}
857
858static void hid_process_event(struct hid_device *hid, struct hid_field *field,
859 struct hid_usage *usage, __s32 value, int interrupt)
860{
861 struct hid_driver *hdrv = hid->driver;
862 int ret;
863
820 hid_dump_input(usage, value); 864 hid_dump_input(usage, value);
865
866 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) {
867 ret = hdrv->event(hid, field, usage, value);
868 if (ret != 0) {
869 if (ret < 0)
870 dbg_hid("%s's event failed with %d\n",
871 hdrv->name, ret);
872 return;
873 }
874 }
875
821 if (hid->claimed & HID_CLAIMED_INPUT) 876 if (hid->claimed & HID_CLAIMED_INPUT)
822 hidinput_hid_event(hid, field, usage, value); 877 hidinput_hid_event(hid, field, usage, value);
823 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 878 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
@@ -946,44 +1001,47 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
946} 1001}
947EXPORT_SYMBOL_GPL(hid_set_field); 1002EXPORT_SYMBOL_GPL(hid_set_field);
948 1003
949int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 1004static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
1005 const u8 *data)
950{ 1006{
951 struct hid_report_enum *report_enum = hid->report_enum + type;
952 struct hid_report *report; 1007 struct hid_report *report;
953 int n, rsize, i; 1008 unsigned int n = 0; /* Normally report number is 0 */
954 1009
955 if (!hid) 1010 /* Device uses numbered reports, data[0] is report number */
956 return -ENODEV; 1011 if (report_enum->numbered)
1012 n = *data;
957 1013
958 if (!size) { 1014 report = report_enum->report_id_hash[n];
959 dbg_hid("empty report\n"); 1015 if (report == NULL)
960 return -1; 1016 dbg_hid("undefined report_id %u received\n", n);
961 }
962 1017
963 dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un"); 1018 return report;
1019}
964 1020
965 n = 0; /* Normally report number is 0 */ 1021void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
966 if (report_enum->numbered) { /* Device uses numbered reports, data[0] is report number */ 1022 int interrupt)
967 n = *data++; 1023{
968 size--; 1024 struct hid_report_enum *report_enum = hid->report_enum + type;
969 } 1025 struct hid_report *report;
1026 unsigned int a;
1027 int rsize, csize = size;
1028 u8 *cdata = data;
970 1029
971 /* dump the report */ 1030 report = hid_get_report(report_enum, data);
972 dbg_hid("report %d (size %u) = ", n, size); 1031 if (!report)
973 for (i = 0; i < size; i++) 1032 return;
974 dbg_hid_line(" %02x", data[i]);
975 dbg_hid_line("\n");
976 1033
977 if (!(report = report_enum->report_id_hash[n])) { 1034 if (report_enum->numbered) {
978 dbg_hid("undefined report_id %d received\n", n); 1035 cdata++;
979 return -1; 1036 csize--;
980 } 1037 }
981 1038
982 rsize = ((report->size - 1) >> 3) + 1; 1039 rsize = ((report->size - 1) >> 3) + 1;
983 1040
984 if (size < rsize) { 1041 if (csize < rsize) {
985 dbg_hid("report %d is too short, (%d < %d)\n", report->id, size, rsize); 1042 dbg_hid("report %d is too short, (%d < %d)\n", report->id,
986 memset(data + size, 0, rsize - size); 1043 csize, rsize);
1044 memset(cdata + csize, 0, rsize - csize);
987 } 1045 }
988 1046
989 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1047 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
@@ -996,24 +1054,661 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
996 hidraw_report_event(hid, data, size); 1054 hidraw_report_event(hid, data, size);
997 } 1055 }
998 1056
999 for (n = 0; n < report->maxfield; n++) 1057 for (a = 0; a < report->maxfield; a++)
1000 hid_input_field(hid, report->field[n], data, interrupt); 1058 hid_input_field(hid, report->field[a], cdata, interrupt);
1001 1059
1002 if (hid->claimed & HID_CLAIMED_INPUT) 1060 if (hid->claimed & HID_CLAIMED_INPUT)
1003 hidinput_report_event(hid, report); 1061 hidinput_report_event(hid, report);
1062}
1063EXPORT_SYMBOL_GPL(hid_report_raw_event);
1064
1065/**
1066 * hid_input_report - report data from lower layer (usb, bt...)
1067 *
1068 * @hid: hid device
1069 * @type: HID report type (HID_*_REPORT)
1070 * @data: report contents
1071 * @size: size of data parameter
1072 * @interrupt: called from atomic?
1073 *
1074 * This is data entry for lower layers.
1075 */
1076int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
1077{
1078 struct hid_report_enum *report_enum = hid->report_enum + type;
1079 struct hid_driver *hdrv = hid->driver;
1080 struct hid_report *report;
1081 unsigned int i;
1082 int ret;
1083
1084 if (!hid || !hid->driver)
1085 return -ENODEV;
1086
1087 if (!size) {
1088 dbg_hid("empty report\n");
1089 return -1;
1090 }
1091
1092 dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
1093
1094 report = hid_get_report(report_enum, data);
1095 if (!report)
1096 return -1;
1097
1098 /* dump the report */
1099 dbg_hid("report %d (size %u) = ", report->id, size);
1100 for (i = 0; i < size; i++)
1101 dbg_hid_line(" %02x", data[i]);
1102 dbg_hid_line("\n");
1103
1104 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
1105 ret = hdrv->raw_event(hid, report, data, size);
1106 if (ret != 0)
1107 return ret < 0 ? ret : 0;
1108 }
1109
1110 hid_report_raw_event(hid, type, data, size, interrupt);
1004 1111
1005 return 0; 1112 return 0;
1006} 1113}
1007EXPORT_SYMBOL_GPL(hid_input_report); 1114EXPORT_SYMBOL_GPL(hid_input_report);
1008 1115
1116static bool hid_match_one_id(struct hid_device *hdev,
1117 const struct hid_device_id *id)
1118{
1119 return id->bus == hdev->bus &&
1120 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
1121 (id->product == HID_ANY_ID || id->product == hdev->product);
1122}
1123
1124static const struct hid_device_id *hid_match_id(struct hid_device *hdev,
1125 const struct hid_device_id *id)
1126{
1127 for (; id->bus; id++)
1128 if (hid_match_one_id(hdev, id))
1129 return id;
1130
1131 return NULL;
1132}
1133
1134static const struct hid_device_id hid_hiddev_list[] = {
1135 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) },
1136 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) },
1137 { }
1138};
1139
1140static bool hid_hiddev(struct hid_device *hdev)
1141{
1142 return !!hid_match_id(hdev, hid_hiddev_list);
1143}
1144
1145int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1146{
1147 static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
1148 "Joystick", "Gamepad", "Keyboard", "Keypad",
1149 "Multi-Axis Controller"
1150 };
1151 const char *type, *bus;
1152 char buf[64];
1153 unsigned int i;
1154 int len;
1155
1156 if (hdev->bus != BUS_USB)
1157 connect_mask &= ~HID_CONNECT_HIDDEV;
1158 if (hid_hiddev(hdev))
1159 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
1160
1161 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev,
1162 connect_mask & HID_CONNECT_HIDINPUT_FORCE))
1163 hdev->claimed |= HID_CLAIMED_INPUT;
1164 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
1165 !hdev->hiddev_connect(hdev,
1166 connect_mask & HID_CONNECT_HIDDEV_FORCE))
1167 hdev->claimed |= HID_CLAIMED_HIDDEV;
1168 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev))
1169 hdev->claimed |= HID_CLAIMED_HIDRAW;
1170
1171 if (!hdev->claimed) {
1172 dev_err(&hdev->dev, "claimed by neither input, hiddev nor "
1173 "hidraw\n");
1174 return -ENODEV;
1175 }
1176
1177 if ((hdev->claimed & HID_CLAIMED_INPUT) &&
1178 (connect_mask & HID_CONNECT_FF) && hdev->ff_init)
1179 hdev->ff_init(hdev);
1180
1181 len = 0;
1182 if (hdev->claimed & HID_CLAIMED_INPUT)
1183 len += sprintf(buf + len, "input");
1184 if (hdev->claimed & HID_CLAIMED_HIDDEV)
1185 len += sprintf(buf + len, "%shiddev%d", len ? "," : "",
1186 hdev->minor);
1187 if (hdev->claimed & HID_CLAIMED_HIDRAW)
1188 len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
1189 ((struct hidraw *)hdev->hidraw)->minor);
1190
1191 type = "Device";
1192 for (i = 0; i < hdev->maxcollection; i++) {
1193 struct hid_collection *col = &hdev->collection[i];
1194 if (col->type == HID_COLLECTION_APPLICATION &&
1195 (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK &&
1196 (col->usage & 0xffff) < ARRAY_SIZE(types)) {
1197 type = types[col->usage & 0xffff];
1198 break;
1199 }
1200 }
1201
1202 switch (hdev->bus) {
1203 case BUS_USB:
1204 bus = "USB";
1205 break;
1206 case BUS_BLUETOOTH:
1207 bus = "BLUETOOTH";
1208 break;
1209 default:
1210 bus = "<UNKNOWN>";
1211 }
1212
1213 dev_info(&hdev->dev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
1214 buf, bus, hdev->version >> 8, hdev->version & 0xff,
1215 type, hdev->name, hdev->phys);
1216
1217 return 0;
1218}
1219EXPORT_SYMBOL_GPL(hid_connect);
1220
1221static const struct hid_device_id hid_blacklist[] = {
1222 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1223 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
1224 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) },
1225 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
1226 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
1227 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
1228 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
1229 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
1230 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
1231 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
1232 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
1233 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
1234 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
1235 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
1236 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
1237 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
1238 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) },
1239 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) },
1240 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) },
1241 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
1242 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
1243 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
1244 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) },
1245 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) },
1246 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) },
1247 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
1248 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
1249 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
1250 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1251 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1252 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
1253 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1254 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1255 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
1256 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
1257 { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) },
1258 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
1259 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
1260 { 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_2) },
1262 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
1263 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) },
1264 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) },
1265 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1266 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
1267 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
1268 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
1269 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
1270 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
1271 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) },
1272 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
1273 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
1274 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
1275 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD) },
1276 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) },
1277 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
1278 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_LX3) },
1279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_V150) },
1280 { 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_WHEEL) },
1282 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) },
1283 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) },
1284 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
1285 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) },
1286 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) },
1287 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) },
1288 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
1289 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
1290 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
1291 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
1292 { 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_WIRELESS_OPTICAL_DESKTOP_3_0) },
1294 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
1295 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1296 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1297 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
1299
1300 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) },
1301 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
1302 { }
1303};
1304
1305static int hid_bus_match(struct device *dev, struct device_driver *drv)
1306{
1307 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1308 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1309
1310 if (!hid_match_id(hdev, hdrv->id_table))
1311 return 0;
1312
1313 /* generic wants all non-blacklisted */
1314 if (!strncmp(hdrv->name, "generic-", 8))
1315 return !hid_match_id(hdev, hid_blacklist);
1316
1317 return 1;
1318}
1319
1320static int hid_device_probe(struct device *dev)
1321{
1322 struct hid_driver *hdrv = container_of(dev->driver,
1323 struct hid_driver, driver);
1324 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1325 const struct hid_device_id *id;
1326 int ret = 0;
1327
1328 if (!hdev->driver) {
1329 id = hid_match_id(hdev, hdrv->id_table);
1330 if (id == NULL)
1331 return -ENODEV;
1332
1333 hdev->driver = hdrv;
1334 if (hdrv->probe) {
1335 ret = hdrv->probe(hdev, id);
1336 } else { /* default probe */
1337 ret = hid_parse(hdev);
1338 if (!ret)
1339 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
1340 }
1341 if (ret)
1342 hdev->driver = NULL;
1343 }
1344 return ret;
1345}
1346
1347static int hid_device_remove(struct device *dev)
1348{
1349 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1350 struct hid_driver *hdrv = hdev->driver;
1351
1352 if (hdrv) {
1353 if (hdrv->remove)
1354 hdrv->remove(hdev);
1355 else /* default remove */
1356 hid_hw_stop(hdev);
1357 hdev->driver = NULL;
1358 }
1359
1360 return 0;
1361}
1362
1363static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
1364{
1365 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1366
1367 if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
1368 hdev->bus, hdev->vendor, hdev->product))
1369 return -ENOMEM;
1370
1371 if (add_uevent_var(env, "HID_NAME=%s", hdev->name))
1372 return -ENOMEM;
1373
1374 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys))
1375 return -ENOMEM;
1376
1377 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq))
1378 return -ENOMEM;
1379
1380 if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X",
1381 hdev->bus, hdev->vendor, hdev->product))
1382 return -ENOMEM;
1383
1384 return 0;
1385}
1386
1387static struct bus_type hid_bus_type = {
1388 .name = "hid",
1389 .match = hid_bus_match,
1390 .probe = hid_device_probe,
1391 .remove = hid_device_remove,
1392 .uevent = hid_uevent,
1393};
1394
1395static const struct hid_device_id hid_ignore_list[] = {
1396 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
1397 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
1398 { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) },
1399 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) },
1400 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) },
1401 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) },
1402 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) },
1403 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) },
1404 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) },
1405 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
1406 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
1407 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
1408 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)},
1409 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
1410 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
1411 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
1412 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
1413 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
1414 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
1415 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1416 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
1417 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
1418 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
1419 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
1420 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
1421 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
1422 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
1423 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) },
1424 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) },
1425 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) },
1426 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) },
1427 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) },
1428 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) },
1429 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) },
1430 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) },
1431 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
1432 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
1433 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
1434 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
1435 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
1436 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
1437 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
1438 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) },
1439 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) },
1440 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) },
1441 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) },
1442 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) },
1443 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) },
1444 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) },
1445 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) },
1446 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) },
1447 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) },
1448 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) },
1449 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) },
1450 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) },
1451 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) },
1452 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) },
1453 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) },
1454 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) },
1455 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) },
1456 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) },
1457 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) },
1458 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) },
1459 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) },
1460 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) },
1461 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) },
1462 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) },
1463 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) },
1464 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) },
1465 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) },
1466 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) },
1467 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) },
1468 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) },
1469 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) },
1470 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) },
1471 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) },
1472 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) },
1473 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) },
1474 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) },
1475 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) },
1476 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) },
1477 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) },
1478 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) },
1479 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) },
1480 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) },
1481 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) },
1482 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
1483 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
1484 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
1485 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
1486 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
1487 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
1488 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
1489 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
1490 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
1491 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
1492 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
1493 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) },
1494 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) },
1495 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) },
1496 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) },
1497 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) },
1498 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
1499 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
1500 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
1501 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
1502 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
1503 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
1504 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) },
1505 { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) },
1506 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) },
1507 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) },
1508 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) },
1509 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) },
1510 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) },
1511 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) },
1512 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) },
1513 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) },
1514 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) },
1515 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) },
1516 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) },
1517 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
1518 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
1519 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
1520 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1521 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1522 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1523 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1524 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
1525 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
1526 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
1527 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1528 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1529 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
1530 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
1531 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
1532 { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
1533 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
1534 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
1535 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
1536 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
1537 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
1538 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
1539 { }
1540};
1541
1542static bool hid_ignore(struct hid_device *hdev)
1543{
1544 switch (hdev->vendor) {
1545 case USB_VENDOR_ID_CODEMERCS:
1546 /* ignore all Code Mercenaries IOWarrior devices */
1547 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
1548 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
1549 return true;
1550 break;
1551 case USB_VENDOR_ID_LOGITECH:
1552 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
1553 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
1554 return true;
1555 break;
1556 }
1557
1558 return !!hid_match_id(hdev, hid_ignore_list);
1559}
1560
1561int hid_add_device(struct hid_device *hdev)
1562{
1563 static atomic_t id = ATOMIC_INIT(0);
1564 int ret;
1565
1566 if (WARN_ON(hdev->status & HID_STAT_ADDED))
1567 return -EBUSY;
1568
1569 /* we need to kill them here, otherwise they will stay allocated to
1570 * wait for coming driver */
1571 if (hid_ignore(hdev))
1572 return -ENODEV;
1573
1574 /* XXX hack, any other cleaner solution < 20 bus_id bytes? */
1575 sprintf(hdev->dev.bus_id, "%04X:%04X:%04X.%04X", hdev->bus,
1576 hdev->vendor, hdev->product, atomic_inc_return(&id));
1577
1578 ret = device_add(&hdev->dev);
1579 if (!ret)
1580 hdev->status |= HID_STAT_ADDED;
1581
1582 return ret;
1583}
1584EXPORT_SYMBOL_GPL(hid_add_device);
1585
1586/**
1587 * hid_allocate_device - allocate new hid device descriptor
1588 *
1589 * Allocate and initialize hid device, so that hid_destroy_device might be
1590 * used to free it.
1591 *
1592 * New hid_device pointer is returned on success, otherwise ERR_PTR encoded
1593 * error value.
1594 */
1595struct hid_device *hid_allocate_device(void)
1596{
1597 struct hid_device *hdev;
1598 unsigned int i;
1599 int ret = -ENOMEM;
1600
1601 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
1602 if (hdev == NULL)
1603 return ERR_PTR(ret);
1604
1605 device_initialize(&hdev->dev);
1606 hdev->dev.release = hid_device_release;
1607 hdev->dev.bus = &hid_bus_type;
1608
1609 hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
1610 sizeof(struct hid_collection), GFP_KERNEL);
1611 if (hdev->collection == NULL)
1612 goto err;
1613 hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
1614
1615 for (i = 0; i < HID_REPORT_TYPES; i++)
1616 INIT_LIST_HEAD(&hdev->report_enum[i].report_list);
1617
1618 return hdev;
1619err:
1620 put_device(&hdev->dev);
1621 return ERR_PTR(ret);
1622}
1623EXPORT_SYMBOL_GPL(hid_allocate_device);
1624
1625static void hid_remove_device(struct hid_device *hdev)
1626{
1627 if (hdev->status & HID_STAT_ADDED) {
1628 device_del(&hdev->dev);
1629 hdev->status &= ~HID_STAT_ADDED;
1630 }
1631}
1632
1633/**
1634 * hid_destroy_device - free previously allocated device
1635 *
1636 * @hdev: hid device
1637 *
1638 * If you allocate hid_device through hid_allocate_device, you should ever
1639 * free by this function.
1640 */
1641void hid_destroy_device(struct hid_device *hdev)
1642{
1643 hid_remove_device(hdev);
1644 put_device(&hdev->dev);
1645}
1646EXPORT_SYMBOL_GPL(hid_destroy_device);
1647
1648int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
1649 const char *mod_name)
1650{
1651 hdrv->driver.name = hdrv->name;
1652 hdrv->driver.bus = &hid_bus_type;
1653 hdrv->driver.owner = owner;
1654 hdrv->driver.mod_name = mod_name;
1655
1656 return driver_register(&hdrv->driver);
1657}
1658EXPORT_SYMBOL_GPL(__hid_register_driver);
1659
1660void hid_unregister_driver(struct hid_driver *hdrv)
1661{
1662 driver_unregister(&hdrv->driver);
1663}
1664EXPORT_SYMBOL_GPL(hid_unregister_driver);
1665
1666#ifdef CONFIG_HID_COMPAT
1667static void hid_compat_load(struct work_struct *ws)
1668{
1669 request_module("hid-dummy");
1670}
1671static DECLARE_WORK(hid_compat_work, hid_compat_load);
1672static struct workqueue_struct *hid_compat_wq;
1673#endif
1674
1009static int __init hid_init(void) 1675static int __init hid_init(void)
1010{ 1676{
1011 return hidraw_init(); 1677 int ret;
1678
1679 ret = bus_register(&hid_bus_type);
1680 if (ret) {
1681 printk(KERN_ERR "HID: can't register hid bus\n");
1682 goto err;
1683 }
1684
1685 ret = hidraw_init();
1686 if (ret)
1687 goto err_bus;
1688
1689#ifdef CONFIG_HID_COMPAT
1690 hid_compat_wq = create_workqueue("hid_compat");
1691 if (!hid_compat_wq) {
1692 hidraw_exit();
1693 goto err;
1694 }
1695 queue_work(hid_compat_wq, &hid_compat_work);
1696#endif
1697
1698 return 0;
1699err_bus:
1700 bus_unregister(&hid_bus_type);
1701err:
1702 return ret;
1012} 1703}
1013 1704
1014static void __exit hid_exit(void) 1705static void __exit hid_exit(void)
1015{ 1706{
1707#ifdef CONFIG_HID_COMPAT
1708 destroy_workqueue(hid_compat_wq);
1709#endif
1016 hidraw_exit(); 1710 hidraw_exit();
1711 bus_unregister(&hid_bus_type);
1017} 1712}
1018 1713
1019module_init(hid_init); 1714module_init(hid_init);
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c
new file mode 100644
index 000000000000..5d69d27b935d
--- /dev/null
+++ b/drivers/hid/hid-cypress.c
@@ -0,0 +1,158 @@
1/*
2 * HID driver for some cypress "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/input.h>
22#include <linux/module.h>
23
24#include "hid-ids.h"
25
26#define CP_RDESC_SWAPPED_MIN_MAX 0x01
27#define CP_2WHEEL_MOUSE_HACK 0x02
28#define CP_2WHEEL_MOUSE_HACK_ON 0x04
29
30/*
31 * Some USB barcode readers from cypress have usage min and usage max in
32 * the wrong order
33 */
34static void cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
35 unsigned int rsize)
36{
37 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
38 unsigned int i;
39
40 if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX))
41 return;
42
43 for (i = 0; i < rsize - 4; i++)
44 if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) {
45 __u8 tmp;
46
47 rdesc[i] = 0x19;
48 rdesc[i + 2] = 0x29;
49 tmp = rdesc[i + 3];
50 rdesc[i + 3] = rdesc[i + 1];
51 rdesc[i + 1] = tmp;
52 }
53}
54
55static int cp_input_mapped(struct hid_device *hdev, struct hid_input *hi,
56 struct hid_field *field, struct hid_usage *usage,
57 unsigned long **bit, int *max)
58{
59 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
60
61 if (!(quirks & CP_2WHEEL_MOUSE_HACK))
62 return 0;
63
64 if (usage->type == EV_REL && usage->code == REL_WHEEL)
65 set_bit(REL_HWHEEL, *bit);
66 if (usage->hid == 0x00090005)
67 return -1;
68
69 return 0;
70}
71
72static int cp_event(struct hid_device *hdev, struct hid_field *field,
73 struct hid_usage *usage, __s32 value)
74{
75 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
76
77 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
78 !usage->type || !(quirks & CP_2WHEEL_MOUSE_HACK))
79 return 0;
80
81 if (usage->hid == 0x00090005) {
82 if (value)
83 quirks |= CP_2WHEEL_MOUSE_HACK_ON;
84 else
85 quirks &= ~CP_2WHEEL_MOUSE_HACK_ON;
86 hid_set_drvdata(hdev, (void *)quirks);
87 return 1;
88 }
89
90 if (usage->code == REL_WHEEL && (quirks & CP_2WHEEL_MOUSE_HACK_ON)) {
91 struct input_dev *input = field->hidinput->input;
92
93 input_event(input, usage->type, REL_HWHEEL, value);
94 return 1;
95 }
96
97 return 0;
98}
99
100static int cp_probe(struct hid_device *hdev, const struct hid_device_id *id)
101{
102 unsigned long quirks = id->driver_data;
103 int ret;
104
105 hid_set_drvdata(hdev, (void *)quirks);
106
107 ret = hid_parse(hdev);
108 if (ret) {
109 dev_err(&hdev->dev, "parse failed\n");
110 goto err_free;
111 }
112
113 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
114 if (ret) {
115 dev_err(&hdev->dev, "hw start failed\n");
116 goto err_free;
117 }
118
119 return 0;
120err_free:
121 return ret;
122}
123
124static const struct hid_device_id cp_devices[] = {
125 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1),
126 .driver_data = CP_RDESC_SWAPPED_MIN_MAX },
127 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2),
128 .driver_data = CP_RDESC_SWAPPED_MIN_MAX },
129 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE),
130 .driver_data = CP_2WHEEL_MOUSE_HACK },
131 { }
132};
133MODULE_DEVICE_TABLE(hid, cp_devices);
134
135static struct hid_driver cp_driver = {
136 .name = "cypress",
137 .id_table = cp_devices,
138 .report_fixup = cp_report_fixup,
139 .input_mapped = cp_input_mapped,
140 .event = cp_event,
141 .probe = cp_probe,
142};
143
144static int cp_init(void)
145{
146 return hid_register_driver(&cp_driver);
147}
148
149static void cp_exit(void)
150{
151 hid_unregister_driver(&cp_driver);
152}
153
154module_init(cp_init);
155module_exit(cp_exit);
156MODULE_LICENSE("GPL");
157
158HID_COMPAT_LOAD_DRIVER(cypress);
diff --git a/drivers/hid/hid-dell.c b/drivers/hid/hid-dell.c
new file mode 100644
index 000000000000..1a0d0dfc62fc
--- /dev/null
+++ b/drivers/hid/hid-dell.c
@@ -0,0 +1,75 @@
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 { }
52};
53MODULE_DEVICE_TABLE(hid, dell_devices);
54
55static struct hid_driver dell_driver = {
56 .name = "dell",
57 .id_table = dell_devices,
58 .probe = dell_probe,
59};
60
61static int dell_init(void)
62{
63 return hid_register_driver(&dell_driver);
64}
65
66static void dell_exit(void)
67{
68 hid_unregister_driver(&dell_driver);
69}
70
71module_init(dell_init);
72module_exit(dell_exit);
73MODULE_LICENSE("GPL");
74
75HID_COMPAT_LOAD_DRIVER(dell);
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
new file mode 100644
index 000000000000..e148f86fb58e
--- /dev/null
+++ b/drivers/hid/hid-dummy.c
@@ -0,0 +1,72 @@
1#include <linux/autoconf.h>
2#include <linux/module.h>
3#include <linux/hid.h>
4
5static int __init hid_dummy_init(void)
6{
7#ifdef CONFIG_HID_A4TECH_MODULE
8 HID_COMPAT_CALL_DRIVER(a4tech);
9#endif
10#ifdef CONFIG_HID_APPLE_MODULE
11 HID_COMPAT_CALL_DRIVER(apple);
12#endif
13#ifdef CONFIG_HID_BELKIN_MODULE
14 HID_COMPAT_CALL_DRIVER(belkin);
15#endif
16#ifdef CONFIG_HID_BRIGHT_MODULE
17 HID_COMPAT_CALL_DRIVER(bright);
18#endif
19#ifdef CONFIG_HID_CHERRY_MODULE
20 HID_COMPAT_CALL_DRIVER(cherry);
21#endif
22#ifdef CONFIG_HID_CHICONY_MODULE
23 HID_COMPAT_CALL_DRIVER(chicony);
24#endif
25#ifdef CONFIG_HID_CYPRESS_MODULE
26 HID_COMPAT_CALL_DRIVER(cypress);
27#endif
28#ifdef CONFIG_HID_DELL_MODULE
29 HID_COMPAT_CALL_DRIVER(dell);
30#endif
31#ifdef CONFIG_HID_EZKEY_MODULE
32 HID_COMPAT_CALL_DRIVER(ezkey);
33#endif
34#ifdef CONFIG_HID_GYRATION_MODULE
35 HID_COMPAT_CALL_DRIVER(gyration);
36#endif
37#ifdef CONFIG_HID_LOGITECH_MODULE
38 HID_COMPAT_CALL_DRIVER(logitech);
39#endif
40#ifdef CONFIG_HID_MICROSOFT_MODULE
41 HID_COMPAT_CALL_DRIVER(microsoft);
42#endif
43#ifdef CONFIG_HID_MONTEREY_MODULE
44 HID_COMPAT_CALL_DRIVER(monterey);
45#endif
46#ifdef CONFIG_HID_PANTHERLORD_MODULE
47 HID_COMPAT_CALL_DRIVER(pantherlord);
48#endif
49#ifdef CONFIG_HID_PETALYNX_MODULE
50 HID_COMPAT_CALL_DRIVER(petalynx);
51#endif
52#ifdef CONFIG_HID_SAMSUNG_MODULE
53 HID_COMPAT_CALL_DRIVER(samsung);
54#endif
55#ifdef CONFIG_HID_SONY_MODULE
56 HID_COMPAT_CALL_DRIVER(sony);
57#endif
58#ifdef CONFIG_HID_SUNPLUS_MODULE
59 HID_COMPAT_CALL_DRIVER(sunplus);
60#endif
61#ifdef CONFIG_THRUSTMASTER_FF_MODULE
62 HID_COMPAT_CALL_DRIVER(thrustmaster);
63#endif
64#ifdef CONFIG_ZEROPLUS_FF_MODULE
65 HID_COMPAT_CALL_DRIVER(zeroplus);
66#endif
67
68 return -EIO;
69}
70module_init(hid_dummy_init);
71
72MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-ezkey.c b/drivers/hid/hid-ezkey.c
new file mode 100644
index 000000000000..deb42f931b7e
--- /dev/null
+++ b/drivers/hid/hid-ezkey.c
@@ -0,0 +1,95 @@
1/*
2 * HID driver for some ezkey "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/input.h>
21#include <linux/hid.h>
22#include <linux/module.h>
23
24#include "hid-ids.h"
25
26#define ez_map_rel(c) hid_map_usage(hi, usage, bit, max, EV_REL, (c))
27#define ez_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
28
29static int ez_input_mapping(struct hid_device *hdev, struct hid_input *hi,
30 struct hid_field *field, struct hid_usage *usage,
31 unsigned long **bit, int *max)
32{
33 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
34 return 0;
35
36 switch (usage->hid & HID_USAGE) {
37 case 0x230: ez_map_key(BTN_MOUSE); break;
38 case 0x231: ez_map_rel(REL_WHEEL); break;
39 /*
40 * this keyboard has a scrollwheel implemented in
41 * totally broken way. We map this usage temporarily
42 * to HWHEEL and handle it in the event quirk handler
43 */
44 case 0x232: ez_map_rel(REL_HWHEEL); break;
45 default:
46 return 0;
47 }
48 return 1;
49}
50
51static int ez_event(struct hid_device *hdev, struct hid_field *field,
52 struct hid_usage *usage, __s32 value)
53{
54 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
55 !usage->type)
56 return 0;
57
58 /* handle the temporary quirky mapping to HWHEEL */
59 if (usage->type == EV_REL && usage->code == REL_HWHEEL) {
60 struct input_dev *input = field->hidinput->input;
61 input_event(input, usage->type, REL_WHEEL, -value);
62 return 1;
63 }
64
65 return 0;
66}
67
68static const struct hid_device_id ez_devices[] = {
69 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
70 { }
71};
72MODULE_DEVICE_TABLE(hid, ez_devices);
73
74static struct hid_driver ez_driver = {
75 .name = "ezkey",
76 .id_table = ez_devices,
77 .input_mapping = ez_input_mapping,
78 .event = ez_event,
79};
80
81static int ez_init(void)
82{
83 return hid_register_driver(&ez_driver);
84}
85
86static void ez_exit(void)
87{
88 hid_unregister_driver(&ez_driver);
89}
90
91module_init(ez_init);
92module_exit(ez_exit);
93MODULE_LICENSE("GPL");
94
95HID_COMPAT_LOAD_DRIVER(ezkey);
diff --git a/drivers/hid/hid-gyration.c b/drivers/hid/hid-gyration.c
new file mode 100644
index 000000000000..ac5120f542cc
--- /dev/null
+++ b/drivers/hid/hid-gyration.c
@@ -0,0 +1,96 @@
1/*
2 * HID driver for some gyration "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/input.h>
21#include <linux/hid.h>
22#include <linux/module.h>
23
24#include "hid-ids.h"
25
26#define gy_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
27 EV_KEY, (c))
28static int gyration_input_mapping(struct hid_device *hdev, struct hid_input *hi,
29 struct hid_field *field, struct hid_usage *usage,
30 unsigned long **bit, int *max)
31{
32 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
33 return 0;
34
35 set_bit(EV_REP, hi->input->evbit);
36 switch (usage->hid & HID_USAGE) {
37 /* Reported on Gyration MCE Remote */
38 case 0x00d: gy_map_key_clear(KEY_HOME); break;
39 case 0x024: gy_map_key_clear(KEY_DVD); break;
40 case 0x025: gy_map_key_clear(KEY_PVR); break;
41 case 0x046: gy_map_key_clear(KEY_MEDIA); break;
42 case 0x047: gy_map_key_clear(KEY_MP3); break;
43 case 0x049: gy_map_key_clear(KEY_CAMERA); break;
44 case 0x04a: gy_map_key_clear(KEY_VIDEO); break;
45
46 default:
47 return 0;
48 }
49 return 1;
50}
51
52static int gyration_event(struct hid_device *hdev, struct hid_field *field,
53 struct hid_usage *usage, __s32 value)
54{
55 struct input_dev *input = field->hidinput->input;
56
57 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK &&
58 (usage->hid & 0xff) == 0x82) {
59 input_event(input, usage->type, usage->code, 1);
60 input_sync(input);
61 input_event(input, usage->type, usage->code, 0);
62 input_sync(input);
63 return 1;
64 }
65
66 return 0;
67}
68
69static const struct hid_device_id gyration_devices[] = {
70 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
71 { }
72};
73MODULE_DEVICE_TABLE(hid, gyration_devices);
74
75static struct hid_driver gyration_driver = {
76 .name = "gyration",
77 .id_table = gyration_devices,
78 .input_mapping = gyration_input_mapping,
79 .event = gyration_event,
80};
81
82static int gyration_init(void)
83{
84 return hid_register_driver(&gyration_driver);
85}
86
87static void gyration_exit(void)
88{
89 hid_unregister_driver(&gyration_driver);
90}
91
92module_init(gyration_init);
93module_exit(gyration_exit);
94MODULE_LICENSE("GPL");
95
96HID_COMPAT_LOAD_DRIVER(gyration);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
new file mode 100644
index 000000000000..aad9ed1b406e
--- /dev/null
+++ b/drivers/hid/hid-ids.h
@@ -0,0 +1,404 @@
1/*
2 * USB HID quirks support for Linux
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 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version.
16 */
17
18#ifndef HID_IDS_H_FILE
19#define HID_IDS_H_FILE
20
21#define USB_VENDOR_ID_A4TECH 0x09da
22#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
23#define USB_DEVICE_ID_A4TECH_X5_005D 0x000a
24
25#define USB_VENDOR_ID_AASHIMA 0x06d6
26#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025
27#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026
28
29#define USB_VENDOR_ID_ACECAD 0x0460
30#define USB_DEVICE_ID_ACECAD_FLAIR 0x0004
31#define USB_DEVICE_ID_ACECAD_302 0x0008
32
33#define USB_VENDOR_ID_ADS_TECH 0x06e1
34#define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155
35
36#define USB_VENDOR_ID_AFATECH 0x15a4
37#define USB_DEVICE_ID_AFATECH_AF9016 0x9016
38
39#define USB_VENDOR_ID_AIPTEK 0x08ca
40#define USB_DEVICE_ID_AIPTEK_01 0x0001
41#define USB_DEVICE_ID_AIPTEK_10 0x0010
42#define USB_DEVICE_ID_AIPTEK_20 0x0020
43#define USB_DEVICE_ID_AIPTEK_21 0x0021
44#define USB_DEVICE_ID_AIPTEK_22 0x0022
45#define USB_DEVICE_ID_AIPTEK_23 0x0023
46#define USB_DEVICE_ID_AIPTEK_24 0x0024
47
48#define USB_VENDOR_ID_AIRCABLE 0x16CA
49#define USB_DEVICE_ID_AIRCABLE1 0x1502
50
51#define USB_VENDOR_ID_ALCOR 0x058f
52#define USB_DEVICE_ID_ALCOR_USBRS232 0x9720
53
54#define USB_VENDOR_ID_ALPS 0x0433
55#define USB_DEVICE_ID_IBM_GAMEPAD 0x1101
56
57#define USB_VENDOR_ID_APPLE 0x05ac
58#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
59#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
60#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
61#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
62#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
63#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
64#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
65#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
66#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
67#define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a
68#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
69#define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c
70#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220
71#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221
72#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222
73#define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223
74#define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224
75#define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225
76#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229
77#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a
78#define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b
79#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c
80#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d
81#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e
82#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
83#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
84#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
85#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
86#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
87#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241
88#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
89
90#define USB_VENDOR_ID_ASUS 0x0b05
91#define USB_DEVICE_ID_ASUS_LCM 0x1726
92
93#define USB_VENDOR_ID_ATEN 0x0557
94#define USB_DEVICE_ID_ATEN_UC100KM 0x2004
95#define USB_DEVICE_ID_ATEN_CS124U 0x2202
96#define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204
97#define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205
98#define USB_DEVICE_ID_ATEN_4PORTKVMC 0x2208
99
100#define USB_VENDOR_ID_AVERMEDIA 0x07ca
101#define USB_DEVICE_ID_AVER_FM_MR800 0xb800
102
103#define USB_VENDOR_ID_BELKIN 0x050d
104#define USB_DEVICE_ID_FLIP_KVM 0x3201
105
106#define USB_VENDOR_ID_BRIGHT 0x1241
107#define USB_DEVICE_ID_BRIGHT_ABNT2 0x1503
108
109#define USB_VENDOR_ID_BERKSHIRE 0x0c98
110#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
111
112#define USB_VENDOR_ID_CHERRY 0x046a
113#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
114
115#define USB_VENDOR_ID_CHIC 0x05fe
116#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014
117
118#define USB_VENDOR_ID_CHICONY 0x04f2
119#define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418
120
121#define USB_VENDOR_ID_CIDC 0x1677
122
123#define USB_VENDOR_ID_CMEDIA 0x0d8c
124#define USB_DEVICE_ID_CM109 0x000e
125
126#define USB_VENDOR_ID_CODEMERCS 0x07c0
127#define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500
128#define USB_DEVICE_ID_CODEMERCS_IOW_LAST 0x15ff
129
130#define USB_VENDOR_ID_CYGNAL 0x10c4
131#define USB_DEVICE_ID_CYGNAL_RADIO_SI470X 0x818a
132
133#define USB_VENDOR_ID_CYPRESS 0x04b4
134#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
135#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
136#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417
137#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
138#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
139
140#define USB_VENDOR_ID_DELL 0x413c
141#define USB_DEVICE_ID_DELL_W7658 0x2005
142#define USB_DEVICE_ID_DELL_SK8115 0x2105
143
144#define USB_VENDOR_ID_DELORME 0x1163
145#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100
146#define USB_DEVICE_ID_DELORME_EM_LT20 0x0200
147
148#define USB_VENDOR_ID_DMI 0x0c0b
149#define USB_DEVICE_ID_DMI_ENC 0x5fab
150
151#define USB_VENDOR_ID_ELO 0x04E7
152#define USB_DEVICE_ID_ELO_TS2700 0x0020
153
154#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
155#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
156
157#define USB_VENDOR_ID_EZKEY 0x0518
158#define USB_DEVICE_ID_BTC_8193 0x0002
159
160#define USB_VENDOR_ID_GAMERON 0x0810
161#define USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR 0x0001
162
163#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc
164
165#define USB_VENDOR_ID_GLAB 0x06c2
166#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
167#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
168#define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040
169#define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044
170#define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045
171#define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051
172#define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053
173#define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058
174
175#define USB_VENDOR_ID_GOTOP 0x08f2
176#define USB_DEVICE_ID_SUPER_Q2 0x007f
177#define USB_DEVICE_ID_GOGOPEN 0x00ce
178#define USB_DEVICE_ID_PENPOWER 0x00f4
179
180#define USB_VENDOR_ID_GREENASIA 0x0e8f
181
182#define USB_VENDOR_ID_GRETAGMACBETH 0x0971
183#define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005
184
185#define USB_VENDOR_ID_GRIFFIN 0x077d
186#define USB_DEVICE_ID_POWERMATE 0x0410
187#define USB_DEVICE_ID_SOUNDKNOB 0x04AA
188
189#define USB_VENDOR_ID_GTCO 0x078c
190#define USB_DEVICE_ID_GTCO_90 0x0090
191#define USB_DEVICE_ID_GTCO_100 0x0100
192#define USB_DEVICE_ID_GTCO_101 0x0101
193#define USB_DEVICE_ID_GTCO_103 0x0103
194#define USB_DEVICE_ID_GTCO_104 0x0104
195#define USB_DEVICE_ID_GTCO_105 0x0105
196#define USB_DEVICE_ID_GTCO_106 0x0106
197#define USB_DEVICE_ID_GTCO_107 0x0107
198#define USB_DEVICE_ID_GTCO_108 0x0108
199#define USB_DEVICE_ID_GTCO_200 0x0200
200#define USB_DEVICE_ID_GTCO_201 0x0201
201#define USB_DEVICE_ID_GTCO_202 0x0202
202#define USB_DEVICE_ID_GTCO_203 0x0203
203#define USB_DEVICE_ID_GTCO_204 0x0204
204#define USB_DEVICE_ID_GTCO_205 0x0205
205#define USB_DEVICE_ID_GTCO_206 0x0206
206#define USB_DEVICE_ID_GTCO_207 0x0207
207#define USB_DEVICE_ID_GTCO_300 0x0300
208#define USB_DEVICE_ID_GTCO_301 0x0301
209#define USB_DEVICE_ID_GTCO_302 0x0302
210#define USB_DEVICE_ID_GTCO_303 0x0303
211#define USB_DEVICE_ID_GTCO_304 0x0304
212#define USB_DEVICE_ID_GTCO_305 0x0305
213#define USB_DEVICE_ID_GTCO_306 0x0306
214#define USB_DEVICE_ID_GTCO_307 0x0307
215#define USB_DEVICE_ID_GTCO_308 0x0308
216#define USB_DEVICE_ID_GTCO_309 0x0309
217#define USB_DEVICE_ID_GTCO_400 0x0400
218#define USB_DEVICE_ID_GTCO_401 0x0401
219#define USB_DEVICE_ID_GTCO_402 0x0402
220#define USB_DEVICE_ID_GTCO_403 0x0403
221#define USB_DEVICE_ID_GTCO_404 0x0404
222#define USB_DEVICE_ID_GTCO_405 0x0405
223#define USB_DEVICE_ID_GTCO_500 0x0500
224#define USB_DEVICE_ID_GTCO_501 0x0501
225#define USB_DEVICE_ID_GTCO_502 0x0502
226#define USB_DEVICE_ID_GTCO_503 0x0503
227#define USB_DEVICE_ID_GTCO_504 0x0504
228#define USB_DEVICE_ID_GTCO_1000 0x1000
229#define USB_DEVICE_ID_GTCO_1001 0x1001
230#define USB_DEVICE_ID_GTCO_1002 0x1002
231#define USB_DEVICE_ID_GTCO_1003 0x1003
232#define USB_DEVICE_ID_GTCO_1004 0x1004
233#define USB_DEVICE_ID_GTCO_1005 0x1005
234#define USB_DEVICE_ID_GTCO_1006 0x1006
235#define USB_DEVICE_ID_GTCO_1007 0x1007
236
237#define USB_VENDOR_ID_GYRATION 0x0c16
238#define USB_DEVICE_ID_GYRATION_REMOTE 0x0002
239
240#define USB_VENDOR_ID_HAPP 0x078b
241#define USB_DEVICE_ID_UGCI_DRIVING 0x0010
242#define USB_DEVICE_ID_UGCI_FLYING 0x0020
243#define USB_DEVICE_ID_UGCI_FIGHTING 0x0030
244
245#define USB_VENDOR_ID_IMATION 0x0718
246#define USB_DEVICE_ID_DISC_STAKKA 0xd000
247
248#define USB_VENDOR_ID_KBGEAR 0x084e
249#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
250
251#define USB_VENDOR_ID_LABTEC 0x1020
252#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006
253
254#define USB_VENDOR_ID_LD 0x0f11
255#define USB_DEVICE_ID_LD_CASSY 0x1000
256#define USB_DEVICE_ID_LD_POCKETCASSY 0x1010
257#define USB_DEVICE_ID_LD_MOBILECASSY 0x1020
258#define USB_DEVICE_ID_LD_JWM 0x1080
259#define USB_DEVICE_ID_LD_DMMP 0x1081
260#define USB_DEVICE_ID_LD_UMIP 0x1090
261#define USB_DEVICE_ID_LD_XRAY1 0x1100
262#define USB_DEVICE_ID_LD_XRAY2 0x1101
263#define USB_DEVICE_ID_LD_VIDEOCOM 0x1200
264#define USB_DEVICE_ID_LD_COM3LAB 0x2000
265#define USB_DEVICE_ID_LD_TELEPORT 0x2010
266#define USB_DEVICE_ID_LD_NETWORKANALYSER 0x2020
267#define USB_DEVICE_ID_LD_POWERCONTROL 0x2030
268#define USB_DEVICE_ID_LD_MACHINETEST 0x2040
269
270#define USB_VENDOR_ID_LOGITECH 0x046d
271#define USB_DEVICE_ID_LOGITECH_LX3 0xc044
272#define USB_DEVICE_ID_LOGITECH_V150 0xc047
273#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
274#define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110
275#define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
276#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD 0xc211
277#define USB_DEVICE_ID_LOGITECH_EXTREME_3D 0xc215
278#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218
279#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219
280#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283
281#define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286
282#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
283#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295
284#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a
285#define USB_DEVICE_ID_LOGITECH_KBD 0xc311
286#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
287#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
288#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
289#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513
290#define USB_DEVICE_ID_DINOVO_DESKTOP 0xc704
291#define USB_DEVICE_ID_DINOVO_EDGE 0xc714
292#define USB_DEVICE_ID_DINOVO_MINI 0xc71f
293#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2 0xca03
294
295#define USB_VENDOR_ID_MCC 0x09db
296#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076
297#define USB_DEVICE_ID_MCC_PMD1208LS 0x007a
298
299#define USB_VENDOR_ID_MGE 0x0463
300#define USB_DEVICE_ID_MGE_UPS 0xffff
301#define USB_DEVICE_ID_MGE_UPS1 0x0001
302
303#define USB_VENDOR_ID_MICROCHIP 0x04d8
304#define USB_DEVICE_ID_PICKIT1 0x0032
305#define USB_DEVICE_ID_PICKIT2 0x0033
306
307#define USB_VENDOR_ID_MICROSOFT 0x045e
308#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
309#define USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0 0x009d
310#define USB_DEVICE_ID_MS_NE4K 0x00db
311#define USB_DEVICE_ID_MS_LK6K 0x00f9
312#define USB_DEVICE_ID_MS_PRESENTER_8K_BT 0x0701
313#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713
314
315
316#define USB_VENDOR_ID_MONTEREY 0x0566
317#define USB_DEVICE_ID_GENIUS_KB29E 0x3004
318
319#define USB_VENDOR_ID_NCR 0x0404
320#define USB_DEVICE_ID_NCR_FIRST 0x0300
321#define USB_DEVICE_ID_NCR_LAST 0x03ff
322
323#define USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR 0x0400
324#define USB_DEVICE_ID_N_S_HARMONY 0xc359
325
326#define USB_VENDOR_ID_NATSU 0x08b7
327#define USB_DEVICE_ID_NATSU_GAMEPAD 0x0001
328
329#define USB_VENDOR_ID_NEC 0x073e
330#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
331
332#define USB_VENDOR_ID_ONTRAK 0x0a07
333#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
334
335#define USB_VENDOR_ID_PANJIT 0x134c
336
337#define USB_VENDOR_ID_PANTHERLORD 0x0810
338#define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001
339
340#define USB_VENDOR_ID_PETALYNX 0x18b1
341#define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
342
343#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43
344#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003
345
346#define USB_VENDOR_ID_SAITEK 0x06a3
347#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
348
349#define USB_VENDOR_ID_SAMSUNG 0x0419
350#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
351
352#define USB_VENDOR_ID_SONY 0x054c
353#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
354
355#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2
356#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038
357
358#define USB_VENDOR_ID_SUN 0x0430
359#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
360
361#define USB_VENDOR_ID_SUNPLUS 0x04fc
362#define USB_DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8
363
364#define USB_VENDOR_ID_TENX 0x1130
365#define USB_DEVICE_ID_TENX_IBUDDY1 0x0001
366#define USB_DEVICE_ID_TENX_IBUDDY2 0x0002
367
368#define USB_VENDOR_ID_THRUSTMASTER 0x044f
369
370#define USB_VENDOR_ID_TOPMAX 0x0663
371#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
372
373#define USB_VENDOR_ID_TURBOX 0x062a
374#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
375
376#define USB_VENDOR_ID_VERNIER 0x08f7
377#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
378#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
379#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
380#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
381#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
382
383#define USB_VENDOR_ID_WACOM 0x056a
384
385#define USB_VENDOR_ID_WISEGROUP 0x0925
386#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101
387#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
388#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201
389#define USB_DEVICE_ID_QUAD_USB_JOYPAD 0x8800
390#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866
391
392#define USB_VENDOR_ID_WISEGROUP_LTD 0x6666
393#define USB_VENDOR_ID_WISEGROUP_LTD2 0x6677
394#define USB_DEVICE_ID_SMARTJOY_DUAL_PLUS 0x8802
395
396#define USB_VENDOR_ID_YEALINK 0x6993
397#define USB_DEVICE_ID_YEALINK_P1K_P4K_B2K 0xb001
398
399#define USB_VENDOR_ID_ZEROPLUS 0x0c12
400
401#define USB_VENDOR_ID_KYE 0x0458
402#define USB_DEVICE_ID_KYE_GPEN_560 0x5003
403
404#endif
diff --git a/drivers/hid/hid-input-quirks.c b/drivers/hid/hid-input-quirks.c
deleted file mode 100644
index 16feea014494..000000000000
--- a/drivers/hid/hid-input-quirks.c
+++ /dev/null
@@ -1,484 +0,0 @@
1/*
2 * HID-input usage mapping quirks
3 *
4 * This is used to handle HID-input mappings for devices violating
5 * HUT 1.12 specification.
6 *
7 * Copyright (c) 2007-2008 Jiri Kosina
8 */
9
10/*
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License
14 */
15
16#include <linux/input.h>
17#include <linux/hid.h>
18
19#define map_abs(c) do { usage->code = c; usage->type = EV_ABS; *bit = input->absbit; *max = ABS_MAX; } while (0)
20#define map_rel(c) do { usage->code = c; usage->type = EV_REL; *bit = input->relbit; *max = REL_MAX; } while (0)
21#define map_key(c) do { usage->code = c; usage->type = EV_KEY; *bit = input->keybit; *max = KEY_MAX; } while (0)
22#define map_led(c) do { usage->code = c; usage->type = EV_LED; *bit = input->ledbit; *max = LED_MAX; } while (0)
23
24#define map_abs_clear(c) do { map_abs(c); clear_bit(c, *bit); } while (0)
25#define map_key_clear(c) do { map_key(c); clear_bit(c, *bit); } while (0)
26
27static int quirk_belkin_wkbd(struct hid_usage *usage, struct input_dev *input,
28 unsigned long **bit, int *max)
29{
30 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
31 return 0;
32
33 switch (usage->hid & HID_USAGE) {
34 case 0x03a: map_key_clear(KEY_SOUND); break;
35 case 0x03b: map_key_clear(KEY_CAMERA); break;
36 case 0x03c: map_key_clear(KEY_DOCUMENTS); break;
37 default:
38 return 0;
39 }
40 return 1;
41}
42
43static int quirk_cherry_cymotion(struct hid_usage *usage, struct input_dev *input,
44 unsigned long **bit, int *max)
45{
46 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
47 return 0;
48
49 switch (usage->hid & HID_USAGE) {
50 case 0x301: map_key_clear(KEY_PROG1); break;
51 case 0x302: map_key_clear(KEY_PROG2); break;
52 case 0x303: map_key_clear(KEY_PROG3); break;
53 default:
54 return 0;
55 }
56 return 1;
57}
58
59static int quirk_logitech_ultrax_remote(struct hid_usage *usage, struct input_dev *input,
60 unsigned long **bit, int *max)
61{
62 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
63 return 0;
64
65 set_bit(EV_REP, input->evbit);
66 switch(usage->hid & HID_USAGE) {
67 /* Reported on Logitech Ultra X Media Remote */
68 case 0x004: map_key_clear(KEY_AGAIN); break;
69 case 0x00d: map_key_clear(KEY_HOME); break;
70 case 0x024: map_key_clear(KEY_SHUFFLE); break;
71 case 0x025: map_key_clear(KEY_TV); break;
72 case 0x026: map_key_clear(KEY_MENU); break;
73 case 0x031: map_key_clear(KEY_AUDIO); break;
74 case 0x032: map_key_clear(KEY_TEXT); break;
75 case 0x033: map_key_clear(KEY_LAST); break;
76 case 0x047: map_key_clear(KEY_MP3); break;
77 case 0x048: map_key_clear(KEY_DVD); break;
78 case 0x049: map_key_clear(KEY_MEDIA); break;
79 case 0x04a: map_key_clear(KEY_VIDEO); break;
80 case 0x04b: map_key_clear(KEY_ANGLE); break;
81 case 0x04c: map_key_clear(KEY_LANGUAGE); break;
82 case 0x04d: map_key_clear(KEY_SUBTITLE); break;
83 case 0x051: map_key_clear(KEY_RED); break;
84 case 0x052: map_key_clear(KEY_CLOSE); break;
85
86 default:
87 return 0;
88 }
89 return 1;
90}
91
92static int quirk_gyration_remote(struct hid_usage *usage, struct input_dev *input,
93 unsigned long **bit, int *max)
94{
95 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
96 return 0;
97
98 set_bit(EV_REP, input->evbit);
99 switch(usage->hid & HID_USAGE) {
100 /* Reported on Gyration MCE Remote */
101 case 0x00d: map_key_clear(KEY_HOME); break;
102 case 0x024: map_key_clear(KEY_DVD); break;
103 case 0x025: map_key_clear(KEY_PVR); break;
104 case 0x046: map_key_clear(KEY_MEDIA); break;
105 case 0x047: map_key_clear(KEY_MP3); break;
106 case 0x049: map_key_clear(KEY_CAMERA); break;
107 case 0x04a: map_key_clear(KEY_VIDEO); break;
108
109 default:
110 return 0;
111 }
112 return 1;
113}
114
115static int quirk_chicony_tactical_pad(struct hid_usage *usage, struct input_dev *input,
116 unsigned long **bit, int *max)
117{
118 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
119 return 0;
120
121 set_bit(EV_REP, input->evbit);
122 switch (usage->hid & HID_USAGE) {
123 case 0xff01: map_key_clear(BTN_1); break;
124 case 0xff02: map_key_clear(BTN_2); break;
125 case 0xff03: map_key_clear(BTN_3); break;
126 case 0xff04: map_key_clear(BTN_4); break;
127 case 0xff05: map_key_clear(BTN_5); break;
128 case 0xff06: map_key_clear(BTN_6); break;
129 case 0xff07: map_key_clear(BTN_7); break;
130 case 0xff08: map_key_clear(BTN_8); break;
131 case 0xff09: map_key_clear(BTN_9); break;
132 case 0xff0a: map_key_clear(BTN_A); break;
133 case 0xff0b: map_key_clear(BTN_B); break;
134 default:
135 return 0;
136 }
137 return 1;
138}
139
140static int quirk_microsoft_ergonomy_kb(struct hid_usage *usage, struct input_dev *input,
141 unsigned long **bit, int *max)
142{
143 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
144 return 0;
145
146 switch(usage->hid & HID_USAGE) {
147 case 0xfd06: map_key_clear(KEY_CHAT); break;
148 case 0xfd07: map_key_clear(KEY_PHONE); break;
149 case 0xff05:
150 set_bit(EV_REP, input->evbit);
151 map_key_clear(KEY_F13);
152 set_bit(KEY_F14, input->keybit);
153 set_bit(KEY_F15, input->keybit);
154 set_bit(KEY_F16, input->keybit);
155 set_bit(KEY_F17, input->keybit);
156 set_bit(KEY_F18, input->keybit);
157 default:
158 return 0;
159 }
160 return 1;
161}
162
163static int quirk_microsoft_presenter_8k(struct hid_usage *usage, struct input_dev *input,
164 unsigned long **bit, int *max)
165{
166 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
167 return 0;
168
169 set_bit(EV_REP, input->evbit);
170 switch(usage->hid & HID_USAGE) {
171 case 0xfd08: map_key_clear(KEY_FORWARD); break;
172 case 0xfd09: map_key_clear(KEY_BACK); break;
173 case 0xfd0b: map_key_clear(KEY_PLAYPAUSE); break;
174 case 0xfd0e: map_key_clear(KEY_CLOSE); break;
175 case 0xfd0f: map_key_clear(KEY_PLAY); break;
176 default:
177 return 0;
178 }
179 return 1;
180}
181
182static int quirk_petalynx_remote(struct hid_usage *usage, struct input_dev *input,
183 unsigned long **bit, int *max)
184{
185 if (((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) &&
186 ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER))
187 return 0;
188
189 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_LOGIVENDOR)
190 switch(usage->hid & HID_USAGE) {
191 case 0x05a: map_key_clear(KEY_TEXT); break;
192 case 0x05b: map_key_clear(KEY_RED); break;
193 case 0x05c: map_key_clear(KEY_GREEN); break;
194 case 0x05d: map_key_clear(KEY_YELLOW); break;
195 case 0x05e: map_key_clear(KEY_BLUE); break;
196 default:
197 return 0;
198 }
199
200 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER)
201 switch(usage->hid & HID_USAGE) {
202 case 0x0f6: map_key_clear(KEY_NEXT); break;
203 case 0x0fa: map_key_clear(KEY_BACK); break;
204 default:
205 return 0;
206 }
207 return 1;
208}
209
210static int quirk_logitech_wireless(struct hid_usage *usage, struct input_dev *input,
211 unsigned long **bit, int *max)
212{
213 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
214 return 0;
215
216 switch (usage->hid & HID_USAGE) {
217 case 0x1001: map_key_clear(KEY_MESSENGER); break;
218 case 0x1003: map_key_clear(KEY_SOUND); break;
219 case 0x1004: map_key_clear(KEY_VIDEO); break;
220 case 0x1005: map_key_clear(KEY_AUDIO); break;
221 case 0x100a: map_key_clear(KEY_DOCUMENTS); break;
222 case 0x1011: map_key_clear(KEY_PREVIOUSSONG); break;
223 case 0x1012: map_key_clear(KEY_NEXTSONG); break;
224 case 0x1013: map_key_clear(KEY_CAMERA); break;
225 case 0x1014: map_key_clear(KEY_MESSENGER); break;
226 case 0x1015: map_key_clear(KEY_RECORD); break;
227 case 0x1016: map_key_clear(KEY_PLAYER); break;
228 case 0x1017: map_key_clear(KEY_EJECTCD); break;
229 case 0x1018: map_key_clear(KEY_MEDIA); break;
230 case 0x1019: map_key_clear(KEY_PROG1); break;
231 case 0x101a: map_key_clear(KEY_PROG2); break;
232 case 0x101b: map_key_clear(KEY_PROG3); break;
233 case 0x101f: map_key_clear(KEY_ZOOMIN); break;
234 case 0x1020: map_key_clear(KEY_ZOOMOUT); break;
235 case 0x1021: map_key_clear(KEY_ZOOMRESET); break;
236 case 0x1023: map_key_clear(KEY_CLOSE); break;
237 case 0x1027: map_key_clear(KEY_MENU); break;
238 /* this one is marked as 'Rotate' */
239 case 0x1028: map_key_clear(KEY_ANGLE); break;
240 case 0x1029: map_key_clear(KEY_SHUFFLE); break;
241 case 0x102a: map_key_clear(KEY_BACK); break;
242 case 0x102b: map_key_clear(KEY_CYCLEWINDOWS); break;
243 case 0x1041: map_key_clear(KEY_BATTERY); break;
244 case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break;
245 case 0x1043: map_key_clear(KEY_SPREADSHEET); break;
246 case 0x1044: map_key_clear(KEY_PRESENTATION); break;
247 case 0x1045: map_key_clear(KEY_UNDO); break;
248 case 0x1046: map_key_clear(KEY_REDO); break;
249 case 0x1047: map_key_clear(KEY_PRINT); break;
250 case 0x1048: map_key_clear(KEY_SAVE); break;
251 case 0x1049: map_key_clear(KEY_PROG1); break;
252 case 0x104a: map_key_clear(KEY_PROG2); break;
253 case 0x104b: map_key_clear(KEY_PROG3); break;
254 case 0x104c: map_key_clear(KEY_PROG4); break;
255
256 default:
257 return 0;
258 }
259 return 1;
260}
261
262static int quirk_cherry_genius_29e(struct hid_usage *usage, struct input_dev *input,
263 unsigned long **bit, int *max)
264{
265 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
266 return 0;
267
268 switch (usage->hid & HID_USAGE) {
269 case 0x156: map_key_clear(KEY_WORDPROCESSOR); break;
270 case 0x157: map_key_clear(KEY_SPREADSHEET); break;
271 case 0x158: map_key_clear(KEY_PRESENTATION); break;
272 case 0x15c: map_key_clear(KEY_STOP); break;
273
274 default:
275 return 0;
276 }
277 return 1;
278}
279
280static int quirk_btc_8193(struct hid_usage *usage, struct input_dev *input,
281 unsigned long **bit, int *max)
282{
283 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
284 return 0;
285
286 switch (usage->hid & HID_USAGE) {
287 case 0x230: map_key(BTN_MOUSE); break;
288 case 0x231: map_rel(REL_WHEEL); break;
289 /*
290 * this keyboard has a scrollwheel implemented in
291 * totally broken way. We map this usage temporarily
292 * to HWHEEL and handle it in the event quirk handler
293 */
294 case 0x232: map_rel(REL_HWHEEL); break;
295
296 default:
297 return 0;
298 }
299 return 1;
300}
301
302static int quirk_sunplus_wdesktop(struct hid_usage *usage, struct input_dev *input,
303 unsigned long **bit, int *max)
304{
305 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
306 return 0;
307
308 switch (usage->hid & HID_USAGE) {
309 case 0x2003: map_key_clear(KEY_ZOOMIN); break;
310 case 0x2103: map_key_clear(KEY_ZOOMOUT); break;
311 default:
312 return 0;
313 }
314 return 1;
315}
316
317#define VENDOR_ID_BELKIN 0x1020
318#define DEVICE_ID_BELKIN_WIRELESS_KEYBOARD 0x0006
319
320#define VENDOR_ID_CHERRY 0x046a
321#define DEVICE_ID_CHERRY_CYMOTION 0x0023
322
323#define VENDOR_ID_CHICONY 0x04f2
324#define DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418
325
326#define VENDOR_ID_EZKEY 0x0518
327#define DEVICE_ID_BTC_8193 0x0002
328
329#define VENDOR_ID_GYRATION 0x0c16
330#define DEVICE_ID_GYRATION_REMOTE 0x0002
331
332#define VENDOR_ID_LOGITECH 0x046d
333#define DEVICE_ID_LOGITECH_RECEIVER 0xc101
334#define DEVICE_ID_S510_RECEIVER 0xc50c
335#define DEVICE_ID_S510_RECEIVER_2 0xc517
336#define DEVICE_ID_MX3000_RECEIVER 0xc513
337
338#define VENDOR_ID_MICROSOFT 0x045e
339#define DEVICE_ID_MS4K 0x00db
340#define DEVICE_ID_MS6K 0x00f9
341#define DEVICE_IS_MS_PRESENTER_8K_BT 0x0701
342#define DEVICE_ID_MS_PRESENTER_8K_USB 0x0713
343
344#define VENDOR_ID_MONTEREY 0x0566
345#define DEVICE_ID_GENIUS_KB29E 0x3004
346
347#define VENDOR_ID_PETALYNX 0x18b1
348#define DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
349
350#define VENDOR_ID_SUNPLUS 0x04fc
351#define DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8
352
353static const struct hid_input_blacklist {
354 __u16 idVendor;
355 __u16 idProduct;
356 int (*quirk)(struct hid_usage *, struct input_dev *, unsigned long **, int *);
357} hid_input_blacklist[] = {
358 { VENDOR_ID_BELKIN, DEVICE_ID_BELKIN_WIRELESS_KEYBOARD, quirk_belkin_wkbd },
359
360 { VENDOR_ID_CHERRY, DEVICE_ID_CHERRY_CYMOTION, quirk_cherry_cymotion },
361
362 { VENDOR_ID_CHICONY, DEVICE_ID_CHICONY_TACTICAL_PAD, quirk_chicony_tactical_pad },
363
364 { VENDOR_ID_EZKEY, DEVICE_ID_BTC_8193, quirk_btc_8193 },
365
366 { VENDOR_ID_GYRATION, DEVICE_ID_GYRATION_REMOTE, quirk_gyration_remote },
367
368 { VENDOR_ID_LOGITECH, DEVICE_ID_LOGITECH_RECEIVER, quirk_logitech_ultrax_remote },
369 { VENDOR_ID_LOGITECH, DEVICE_ID_S510_RECEIVER, quirk_logitech_wireless },
370 { VENDOR_ID_LOGITECH, DEVICE_ID_S510_RECEIVER_2, quirk_logitech_wireless },
371 { VENDOR_ID_LOGITECH, DEVICE_ID_MX3000_RECEIVER, quirk_logitech_wireless },
372
373 { VENDOR_ID_MICROSOFT, DEVICE_ID_MS4K, quirk_microsoft_ergonomy_kb },
374 { VENDOR_ID_MICROSOFT, DEVICE_ID_MS6K, quirk_microsoft_ergonomy_kb },
375 { VENDOR_ID_MICROSOFT, DEVICE_IS_MS_PRESENTER_8K_BT, quirk_microsoft_presenter_8k },
376 { VENDOR_ID_MICROSOFT, DEVICE_ID_MS_PRESENTER_8K_USB, quirk_microsoft_presenter_8k },
377
378 { VENDOR_ID_MONTEREY, DEVICE_ID_GENIUS_KB29E, quirk_cherry_genius_29e },
379
380 { VENDOR_ID_PETALYNX, DEVICE_ID_PETALYNX_MAXTER_REMOTE, quirk_petalynx_remote },
381
382 { VENDOR_ID_SUNPLUS, DEVICE_ID_SUNPLUS_WDESKTOP, quirk_sunplus_wdesktop },
383
384 { 0, 0, NULL }
385};
386
387int hidinput_mapping_quirks(struct hid_usage *usage,
388 struct input_dev *input,
389 unsigned long **bit, int *max)
390{
391 struct hid_device *device = input_get_drvdata(input);
392 int i = 0;
393
394 while (hid_input_blacklist[i].quirk) {
395 if (hid_input_blacklist[i].idVendor == device->vendor &&
396 hid_input_blacklist[i].idProduct == device->product)
397 return hid_input_blacklist[i].quirk(usage, input, bit, max);
398 i++;
399 }
400 return 0;
401}
402
403int hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
404{
405 struct input_dev *input;
406
407 input = field->hidinput->input;
408
409 if (((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005))
410 || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) {
411 if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
412 else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
413 return 1;
414 }
415
416 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
417 (usage->type == EV_REL) &&
418 (usage->code == REL_WHEEL)) {
419 hid->delayed_value = value;
420 return 1;
421 }
422
423 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
424 (usage->hid == 0x000100b8)) {
425 input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value);
426 return 1;
427 }
428
429 if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
430 input_event(input, usage->type, usage->code, -value);
431 return 1;
432 }
433
434 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) {
435 input_event(input, usage->type, REL_HWHEEL, value);
436 return 1;
437 }
438
439 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value))
440 return 1;
441
442 /* Handling MS keyboards special buttons */
443 if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS &&
444 usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
445 int key = 0;
446 static int last_key = 0;
447 switch (value) {
448 case 0x01: key = KEY_F14; break;
449 case 0x02: key = KEY_F15; break;
450 case 0x04: key = KEY_F16; break;
451 case 0x08: key = KEY_F17; break;
452 case 0x10: key = KEY_F18; break;
453 default: break;
454 }
455 if (key) {
456 input_event(input, usage->type, key, 1);
457 last_key = key;
458 } else {
459 input_event(input, usage->type, last_key, 0);
460 }
461 }
462
463 /* handle the temporary quirky mapping to HWHEEL */
464 if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT &&
465 usage->type == EV_REL && usage->code == REL_HWHEEL) {
466 input_event(input, usage->type, REL_WHEEL, -value);
467 return 1;
468 }
469
470 /* Gyration MCE remote "Sleep" key */
471 if (hid->vendor == VENDOR_ID_GYRATION &&
472 hid->product == DEVICE_ID_GYRATION_REMOTE &&
473 (usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK &&
474 (usage->hid & 0xff) == 0x82) {
475 input_event(input, usage->type, usage->code, 1);
476 input_sync(input);
477 input_event(input, usage->type, usage->code, 0);
478 input_sync(input);
479 return 1;
480 }
481 return 0;
482}
483
484
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 1b2e8dc3398d..7f183b7147e1 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -32,11 +32,6 @@
32#include <linux/hid.h> 32#include <linux/hid.h>
33#include <linux/hid-debug.h> 33#include <linux/hid-debug.h>
34 34
35static int hid_apple_fnmode = 1;
36module_param_named(pb_fnmode, hid_apple_fnmode, int, 0644);
37MODULE_PARM_DESC(pb_fnmode,
38 "Mode of fn key on Apple keyboards (0 = disabled, 1 = fkeyslast, 2 = fkeysfirst)");
39
40#define unk KEY_UNKNOWN 35#define unk KEY_UNKNOWN
41 36
42static const unsigned char hid_keyboard[256] = { 37static const unsigned char hid_keyboard[256] = {
@@ -58,227 +53,20 @@ static const unsigned char hid_keyboard[256] = {
58 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk 53 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk
59}; 54};
60 55
61/* extended mapping for certain Logitech hardware (Logitech cordless desktop LX500) */
62#define LOGITECH_EXPANDED_KEYMAP_SIZE 80
63static int logitech_expanded_keymap[LOGITECH_EXPANDED_KEYMAP_SIZE] = {
64 0,216, 0,213,175,156, 0, 0, 0, 0,
65 144, 0, 0, 0, 0, 0, 0, 0, 0,212,
66 174,167,152,161,112, 0, 0, 0,154, 0,
67 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
68 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0,183,184,185,186,187,
71 188,189,190,191,192,193,194, 0, 0, 0
72};
73
74static const struct { 56static const struct {
75 __s32 x; 57 __s32 x;
76 __s32 y; 58 __s32 y;
77} hid_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}}; 59} hid_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
78 60
79#define map_abs(c) do { usage->code = c; usage->type = EV_ABS; bit = input->absbit; max = ABS_MAX; } while (0) 61#define map_abs(c) hid_map_usage(hidinput, usage, &bit, &max, EV_ABS, (c))
80#define map_rel(c) do { usage->code = c; usage->type = EV_REL; bit = input->relbit; max = REL_MAX; } while (0) 62#define map_rel(c) hid_map_usage(hidinput, usage, &bit, &max, EV_REL, (c))
81#define map_key(c) do { usage->code = c; usage->type = EV_KEY; bit = input->keybit; max = KEY_MAX; } while (0) 63#define map_key(c) hid_map_usage(hidinput, usage, &bit, &max, EV_KEY, (c))
82#define map_led(c) do { usage->code = c; usage->type = EV_LED; bit = input->ledbit; max = LED_MAX; } while (0) 64#define map_led(c) hid_map_usage(hidinput, usage, &bit, &max, EV_LED, (c))
83
84#define map_abs_clear(c) do { map_abs(c); clear_bit(c, bit); } while (0)
85#define map_key_clear(c) do { map_key(c); clear_bit(c, bit); } while (0)
86
87#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
88
89struct hidinput_key_translation {
90 u16 from;
91 u16 to;
92 u8 flags;
93};
94
95#define APPLE_FLAG_FKEY 0x01
96
97static struct hidinput_key_translation apple_fn_keys[] = {
98 { KEY_BACKSPACE, KEY_DELETE },
99 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
100 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
101 { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Exposé */
102 { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */
103 { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
104 { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
105 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
106 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
107 { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
108 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
109 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
110 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
111 { KEY_UP, KEY_PAGEUP },
112 { KEY_DOWN, KEY_PAGEDOWN },
113 { KEY_LEFT, KEY_HOME },
114 { KEY_RIGHT, KEY_END },
115 { }
116};
117
118static struct hidinput_key_translation powerbook_fn_keys[] = {
119 { KEY_BACKSPACE, KEY_DELETE },
120 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
121 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
122 { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
123 { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
124 { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
125 { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
126 { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
127 { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
128 { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
129 { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
130 { KEY_UP, KEY_PAGEUP },
131 { KEY_DOWN, KEY_PAGEDOWN },
132 { KEY_LEFT, KEY_HOME },
133 { KEY_RIGHT, KEY_END },
134 { }
135};
136
137static struct hidinput_key_translation powerbook_numlock_keys[] = {
138 { KEY_J, KEY_KP1 },
139 { KEY_K, KEY_KP2 },
140 { KEY_L, KEY_KP3 },
141 { KEY_U, KEY_KP4 },
142 { KEY_I, KEY_KP5 },
143 { KEY_O, KEY_KP6 },
144 { KEY_7, KEY_KP7 },
145 { KEY_8, KEY_KP8 },
146 { KEY_9, KEY_KP9 },
147 { KEY_M, KEY_KP0 },
148 { KEY_DOT, KEY_KPDOT },
149 { KEY_SLASH, KEY_KPPLUS },
150 { KEY_SEMICOLON, KEY_KPMINUS },
151 { KEY_P, KEY_KPASTERISK },
152 { KEY_MINUS, KEY_KPEQUAL },
153 { KEY_0, KEY_KPSLASH },
154 { KEY_F6, KEY_NUMLOCK },
155 { KEY_KPENTER, KEY_KPENTER },
156 { KEY_BACKSPACE, KEY_BACKSPACE },
157 { }
158};
159
160static struct hidinput_key_translation apple_iso_keyboard[] = {
161 { KEY_GRAVE, KEY_102ND },
162 { KEY_102ND, KEY_GRAVE },
163 { }
164};
165 65
166static struct hidinput_key_translation *find_translation(struct hidinput_key_translation *table, u16 from) 66#define map_abs_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
167{ 67 &max, EV_ABS, (c))
168 struct hidinput_key_translation *trans; 68#define map_key_clear(c) hid_map_usage_clear(hidinput, usage, &bit, \
169 69 &max, EV_KEY, (c))
170 /* Look for the translation */
171 for (trans = table; trans->from; trans++)
172 if (trans->from == from)
173 return trans;
174
175 return NULL;
176}
177
178int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
179 struct hid_usage *usage, __s32 value)
180{
181 struct hidinput_key_translation *trans;
182
183 if (usage->code == KEY_FN) {
184 if (value) hid->quirks |= HID_QUIRK_APPLE_FN_ON;
185 else hid->quirks &= ~HID_QUIRK_APPLE_FN_ON;
186
187 input_event(input, usage->type, usage->code, value);
188
189 return 1;
190 }
191
192 if (hid_apple_fnmode) {
193 int do_translate;
194
195 trans = find_translation((hid->product < 0x220 ||
196 hid->product >= 0x300) ?
197 powerbook_fn_keys : apple_fn_keys,
198 usage->code);
199 if (trans) {
200 if (test_bit(usage->code, hid->apple_pressed_fn))
201 do_translate = 1;
202 else if (trans->flags & APPLE_FLAG_FKEY)
203 do_translate =
204 (hid_apple_fnmode == 2 && (hid->quirks & HID_QUIRK_APPLE_FN_ON)) ||
205 (hid_apple_fnmode == 1 && !(hid->quirks & HID_QUIRK_APPLE_FN_ON));
206 else
207 do_translate = (hid->quirks & HID_QUIRK_APPLE_FN_ON);
208
209 if (do_translate) {
210 if (value)
211 set_bit(usage->code, hid->apple_pressed_fn);
212 else
213 clear_bit(usage->code, hid->apple_pressed_fn);
214
215 input_event(input, usage->type, trans->to, value);
216
217 return 1;
218 }
219 }
220
221 if (hid->quirks & HID_QUIRK_APPLE_NUMLOCK_EMULATION && (
222 test_bit(usage->code, hid->pb_pressed_numlock) ||
223 test_bit(LED_NUML, input->led))) {
224 trans = find_translation(powerbook_numlock_keys, usage->code);
225
226 if (trans) {
227 if (value)
228 set_bit(usage->code, hid->pb_pressed_numlock);
229 else
230 clear_bit(usage->code, hid->pb_pressed_numlock);
231
232 input_event(input, usage->type, trans->to, value);
233 }
234
235 return 1;
236 }
237 }
238
239 if (hid->quirks & HID_QUIRK_APPLE_ISO_KEYBOARD) {
240 trans = find_translation(apple_iso_keyboard, usage->code);
241 if (trans) {
242 input_event(input, usage->type, trans->to, value);
243 return 1;
244 }
245 }
246
247 return 0;
248}
249
250static void hidinput_apple_setup(struct input_dev *input)
251{
252 struct hidinput_key_translation *trans;
253
254 set_bit(KEY_NUMLOCK, input->keybit);
255
256 /* Enable all needed keys */
257 for (trans = apple_fn_keys; trans->from; trans++)
258 set_bit(trans->to, input->keybit);
259
260 for (trans = powerbook_fn_keys; trans->from; trans++)
261 set_bit(trans->to, input->keybit);
262
263 for (trans = powerbook_numlock_keys; trans->from; trans++)
264 set_bit(trans->to, input->keybit);
265
266 for (trans = apple_iso_keyboard; trans->from; trans++)
267 set_bit(trans->to, input->keybit);
268
269}
270#else
271inline int hidinput_apple_event(struct hid_device *hid,
272 struct input_dev *input,
273 struct hid_usage *usage, __s32 value)
274{
275 return 0;
276}
277
278static inline void hidinput_apple_setup(struct input_dev *input)
279{
280}
281#endif
282 70
283static inline int match_scancode(int code, int scancode) 71static inline int match_scancode(int code, int scancode)
284{ 72{
@@ -366,7 +154,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
366{ 154{
367 struct input_dev *input = hidinput->input; 155 struct input_dev *input = hidinput->input;
368 struct hid_device *device = input_get_drvdata(input); 156 struct hid_device *device = input_get_drvdata(input);
369 int max = 0, code, ret; 157 int max = 0, code;
370 unsigned long *bit = NULL; 158 unsigned long *bit = NULL;
371 159
372 field->hidinput = hidinput; 160 field->hidinput = hidinput;
@@ -385,406 +173,345 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
385 goto ignore; 173 goto ignore;
386 } 174 }
387 175
388 /* handle input mappings for quirky devices */ 176 if (device->driver->input_mapping) {
389 ret = hidinput_mapping_quirks(usage, input, &bit, &max); 177 int ret = device->driver->input_mapping(device, hidinput, field,
390 if (ret) 178 usage, &bit, &max);
391 goto mapped; 179 if (ret > 0)
180 goto mapped;
181 if (ret < 0)
182 goto ignore;
183 }
392 184
393 switch (usage->hid & HID_USAGE_PAGE) { 185 switch (usage->hid & HID_USAGE_PAGE) {
186 case HID_UP_UNDEFINED:
187 goto ignore;
394 188
395 case HID_UP_UNDEFINED: 189 case HID_UP_KEYBOARD:
396 goto ignore; 190 set_bit(EV_REP, input->evbit);
397
398 case HID_UP_KEYBOARD:
399 191
400 set_bit(EV_REP, input->evbit); 192 if ((usage->hid & HID_USAGE) < 256) {
193 if (!hid_keyboard[usage->hid & HID_USAGE]) goto ignore;
194 map_key_clear(hid_keyboard[usage->hid & HID_USAGE]);
195 } else
196 map_key(KEY_UNKNOWN);
401 197
402 if ((usage->hid & HID_USAGE) < 256) { 198 break;
403 if (!hid_keyboard[usage->hid & HID_USAGE]) goto ignore;
404 map_key_clear(hid_keyboard[usage->hid & HID_USAGE]);
405 } else
406 map_key(KEY_UNKNOWN);
407 199
408 break; 200 case HID_UP_BUTTON:
201 code = ((usage->hid - 1) & 0xf);
409 202
410 case HID_UP_BUTTON: 203 switch (field->application) {
411 204 case HID_GD_MOUSE:
412 code = ((usage->hid - 1) & 0xf); 205 case HID_GD_POINTER: code += 0x110; break;
413 206 case HID_GD_JOYSTICK: code += 0x120; break;
414 switch (field->application) { 207 case HID_GD_GAMEPAD: code += 0x130; break;
415 case HID_GD_MOUSE: 208 default:
416 case HID_GD_POINTER: code += 0x110; break; 209 switch (field->physical) {
417 case HID_GD_JOYSTICK: code += 0x120; break; 210 case HID_GD_MOUSE:
418 case HID_GD_GAMEPAD: code += 0x130; break; 211 case HID_GD_POINTER: code += 0x110; break;
419 default: 212 case HID_GD_JOYSTICK: code += 0x120; break;
420 switch (field->physical) { 213 case HID_GD_GAMEPAD: code += 0x130; break;
421 case HID_GD_MOUSE: 214 default: code += 0x100;
422 case HID_GD_POINTER: code += 0x110; break;
423 case HID_GD_JOYSTICK: code += 0x120; break;
424 case HID_GD_GAMEPAD: code += 0x130; break;
425 default: code += 0x100;
426 }
427 }
428
429 /* Special handling for Logitech Cordless Desktop */
430 if (field->application != HID_GD_MOUSE) {
431 if (device->quirks & HID_QUIRK_LOGITECH_EXPANDED_KEYMAP) {
432 int hid = usage->hid & HID_USAGE;
433 if (hid < LOGITECH_EXPANDED_KEYMAP_SIZE && logitech_expanded_keymap[hid] != 0)
434 code = logitech_expanded_keymap[hid];
435 }
436 } else {
437 if (device->quirks & HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL) {
438 int hid = usage->hid & HID_USAGE;
439 if (hid == 7 || hid == 8)
440 goto ignore;
441 }
442 } 215 }
216 }
443 217
444 map_key(code); 218 map_key(code);
445 break; 219 break;
446 220
447 221 case HID_UP_SIMULATION:
448 case HID_UP_SIMULATION: 222 switch (usage->hid & 0xffff) {
449 223 case 0xba: map_abs(ABS_RUDDER); break;
450 switch (usage->hid & 0xffff) { 224 case 0xbb: map_abs(ABS_THROTTLE); break;
451 case 0xba: map_abs(ABS_RUDDER); break; 225 case 0xc4: map_abs(ABS_GAS); break;
452 case 0xbb: map_abs(ABS_THROTTLE); break; 226 case 0xc5: map_abs(ABS_BRAKE); break;
453 case 0xc4: map_abs(ABS_GAS); break; 227 case 0xc8: map_abs(ABS_WHEEL); break;
454 case 0xc5: map_abs(ABS_BRAKE); break; 228 default: goto ignore;
455 case 0xc8: map_abs(ABS_WHEEL); break; 229 }
456 default: goto ignore; 230 break;
231
232 case HID_UP_GENDESK:
233 if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */
234 switch (usage->hid & 0xf) {
235 case 0x1: map_key_clear(KEY_POWER); break;
236 case 0x2: map_key_clear(KEY_SLEEP); break;
237 case 0x3: map_key_clear(KEY_WAKEUP); break;
238 default: goto unknown;
457 } 239 }
458 break; 240 break;
241 }
459 242
460 case HID_UP_GENDESK: 243 if ((usage->hid & 0xf0) == 0x90) { /* D-pad */
461
462 if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */
463 switch (usage->hid & 0xf) {
464 case 0x1: map_key_clear(KEY_POWER); break;
465 case 0x2: map_key_clear(KEY_SLEEP); break;
466 case 0x3: map_key_clear(KEY_WAKEUP); break;
467 default: goto unknown;
468 }
469 break;
470 }
471
472 if ((usage->hid & 0xf0) == 0x90) { /* D-pad */
473 switch (usage->hid) {
474 case HID_GD_UP: usage->hat_dir = 1; break;
475 case HID_GD_DOWN: usage->hat_dir = 5; break;
476 case HID_GD_RIGHT: usage->hat_dir = 3; break;
477 case HID_GD_LEFT: usage->hat_dir = 7; break;
478 default: goto unknown;
479 }
480 if (field->dpad) {
481 map_abs(field->dpad);
482 goto ignore;
483 }
484 map_abs(ABS_HAT0X);
485 break;
486 }
487
488 switch (usage->hid) { 244 switch (usage->hid) {
489 245 case HID_GD_UP: usage->hat_dir = 1; break;
490 /* These usage IDs map directly to the usage codes. */ 246 case HID_GD_DOWN: usage->hat_dir = 5; break;
491 case HID_GD_X: case HID_GD_Y: case HID_GD_Z: 247 case HID_GD_RIGHT: usage->hat_dir = 3; break;
492 case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: 248 case HID_GD_LEFT: usage->hat_dir = 7; break;
493 case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL: 249 default: goto unknown;
494 if (field->flags & HID_MAIN_ITEM_RELATIVE)
495 map_rel(usage->hid & 0xf);
496 else
497 map_abs(usage->hid & 0xf);
498 break;
499
500 case HID_GD_HATSWITCH:
501 usage->hat_min = field->logical_minimum;
502 usage->hat_max = field->logical_maximum;
503 map_abs(ABS_HAT0X);
504 break;
505
506 case HID_GD_START: map_key_clear(BTN_START); break;
507 case HID_GD_SELECT: map_key_clear(BTN_SELECT); break;
508
509 default: goto unknown;
510 } 250 }
511 251 if (field->dpad) {
512 break; 252 map_abs(field->dpad);
513 253 goto ignore;
514 case HID_UP_LED:
515
516 switch (usage->hid & 0xffff) { /* HID-Value: */
517 case 0x01: map_led (LED_NUML); break; /* "Num Lock" */
518 case 0x02: map_led (LED_CAPSL); break; /* "Caps Lock" */
519 case 0x03: map_led (LED_SCROLLL); break; /* "Scroll Lock" */
520 case 0x04: map_led (LED_COMPOSE); break; /* "Compose" */
521 case 0x05: map_led (LED_KANA); break; /* "Kana" */
522 case 0x27: map_led (LED_SLEEP); break; /* "Stand-By" */
523 case 0x4c: map_led (LED_SUSPEND); break; /* "System Suspend" */
524 case 0x09: map_led (LED_MUTE); break; /* "Mute" */
525 case 0x4b: map_led (LED_MISC); break; /* "Generic Indicator" */
526 case 0x19: map_led (LED_MAIL); break; /* "Message Waiting" */
527 case 0x4d: map_led (LED_CHARGING); break; /* "External Power Connected" */
528
529 default: goto ignore;
530 } 254 }
255 map_abs(ABS_HAT0X);
531 break; 256 break;
257 }
532 258
533 case HID_UP_DIGITIZER: 259 switch (usage->hid) {
534 260 /* These usage IDs map directly to the usage codes. */
535 switch (usage->hid & 0xff) { 261 case HID_GD_X: case HID_GD_Y: case HID_GD_Z:
536 262 case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ:
537 case 0x30: /* TipPressure */ 263 case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL:
538 if (!test_bit(BTN_TOUCH, input->keybit)) { 264 if (field->flags & HID_MAIN_ITEM_RELATIVE)
539 device->quirks |= HID_QUIRK_NOTOUCH; 265 map_rel(usage->hid & 0xf);
540 set_bit(EV_KEY, input->evbit); 266 else
541 set_bit(BTN_TOUCH, input->keybit); 267 map_abs(usage->hid & 0xf);
542 } 268 break;
543
544 map_abs_clear(ABS_PRESSURE);
545 break;
546
547 case 0x32: /* InRange */
548 switch (field->physical & 0xff) {
549 case 0x21: map_key(BTN_TOOL_MOUSE); break;
550 case 0x22: map_key(BTN_TOOL_FINGER); break;
551 default: map_key(BTN_TOOL_PEN); break;
552 }
553 break;
554 269
555 case 0x3c: /* Invert */ 270 case HID_GD_HATSWITCH:
556 map_key_clear(BTN_TOOL_RUBBER); 271 usage->hat_min = field->logical_minimum;
557 break; 272 usage->hat_max = field->logical_maximum;
273 map_abs(ABS_HAT0X);
274 break;
558 275
559 case 0x33: /* Touch */ 276 case HID_GD_START: map_key_clear(BTN_START); break;
560 case 0x42: /* TipSwitch */ 277 case HID_GD_SELECT: map_key_clear(BTN_SELECT); break;
561 case 0x43: /* TipSwitch2 */
562 device->quirks &= ~HID_QUIRK_NOTOUCH;
563 map_key_clear(BTN_TOUCH);
564 break;
565 278
566 case 0x44: /* BarrelSwitch */ 279 default: goto unknown;
567 map_key_clear(BTN_STYLUS); 280 }
568 break;
569 281
570 default: goto unknown; 282 break;
283
284 case HID_UP_LED:
285 switch (usage->hid & 0xffff) { /* HID-Value: */
286 case 0x01: map_led (LED_NUML); break; /* "Num Lock" */
287 case 0x02: map_led (LED_CAPSL); break; /* "Caps Lock" */
288 case 0x03: map_led (LED_SCROLLL); break; /* "Scroll Lock" */
289 case 0x04: map_led (LED_COMPOSE); break; /* "Compose" */
290 case 0x05: map_led (LED_KANA); break; /* "Kana" */
291 case 0x27: map_led (LED_SLEEP); break; /* "Stand-By" */
292 case 0x4c: map_led (LED_SUSPEND); break; /* "System Suspend" */
293 case 0x09: map_led (LED_MUTE); break; /* "Mute" */
294 case 0x4b: map_led (LED_MISC); break; /* "Generic Indicator" */
295 case 0x19: map_led (LED_MAIL); break; /* "Message Waiting" */
296 case 0x4d: map_led (LED_CHARGING); break; /* "External Power Connected" */
297
298 default: goto ignore;
299 }
300 break;
301
302 case HID_UP_DIGITIZER:
303 switch (usage->hid & 0xff) {
304 case 0x30: /* TipPressure */
305 if (!test_bit(BTN_TOUCH, input->keybit)) {
306 device->quirks |= HID_QUIRK_NOTOUCH;
307 set_bit(EV_KEY, input->evbit);
308 set_bit(BTN_TOUCH, input->keybit);
571 } 309 }
310 map_abs_clear(ABS_PRESSURE);
572 break; 311 break;
573 312
574 case HID_UP_CONSUMER: /* USB HUT v1.1, pages 56-62 */ 313 case 0x32: /* InRange */
575 314 switch (field->physical & 0xff) {
576 switch (usage->hid & HID_USAGE) { 315 case 0x21: map_key(BTN_TOOL_MOUSE); break;
577 case 0x000: goto ignore; 316 case 0x22: map_key(BTN_TOOL_FINGER); break;
578 case 0x034: map_key_clear(KEY_SLEEP); break; 317 default: map_key(BTN_TOOL_PEN); break;
579 case 0x036: map_key_clear(BTN_MISC); break;
580
581 case 0x040: map_key_clear(KEY_MENU); break;
582 case 0x045: map_key_clear(KEY_RADIO); break;
583
584 case 0x083: map_key_clear(KEY_LAST); break;
585 case 0x088: map_key_clear(KEY_PC); break;
586 case 0x089: map_key_clear(KEY_TV); break;
587 case 0x08a: map_key_clear(KEY_WWW); break;
588 case 0x08b: map_key_clear(KEY_DVD); break;
589 case 0x08c: map_key_clear(KEY_PHONE); break;
590 case 0x08d: map_key_clear(KEY_PROGRAM); break;
591 case 0x08e: map_key_clear(KEY_VIDEOPHONE); break;
592 case 0x08f: map_key_clear(KEY_GAMES); break;
593 case 0x090: map_key_clear(KEY_MEMO); break;
594 case 0x091: map_key_clear(KEY_CD); break;
595 case 0x092: map_key_clear(KEY_VCR); break;
596 case 0x093: map_key_clear(KEY_TUNER); break;
597 case 0x094: map_key_clear(KEY_EXIT); break;
598 case 0x095: map_key_clear(KEY_HELP); break;
599 case 0x096: map_key_clear(KEY_TAPE); break;
600 case 0x097: map_key_clear(KEY_TV2); break;
601 case 0x098: map_key_clear(KEY_SAT); break;
602 case 0x09a: map_key_clear(KEY_PVR); break;
603
604 case 0x09c: map_key_clear(KEY_CHANNELUP); break;
605 case 0x09d: map_key_clear(KEY_CHANNELDOWN); break;
606 case 0x0a0: map_key_clear(KEY_VCR2); break;
607
608 case 0x0b0: map_key_clear(KEY_PLAY); break;
609 case 0x0b1: map_key_clear(KEY_PAUSE); break;
610 case 0x0b2: map_key_clear(KEY_RECORD); break;
611 case 0x0b3: map_key_clear(KEY_FASTFORWARD); break;
612 case 0x0b4: map_key_clear(KEY_REWIND); break;
613 case 0x0b5: map_key_clear(KEY_NEXTSONG); break;
614 case 0x0b6: map_key_clear(KEY_PREVIOUSSONG); break;
615 case 0x0b7: map_key_clear(KEY_STOPCD); break;
616 case 0x0b8: map_key_clear(KEY_EJECTCD); break;
617 case 0x0bc: map_key_clear(KEY_MEDIA_REPEAT); break;
618
619 case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break;
620 case 0x0e0: map_abs_clear(ABS_VOLUME); break;
621 case 0x0e2: map_key_clear(KEY_MUTE); break;
622 case 0x0e5: map_key_clear(KEY_BASSBOOST); break;
623 case 0x0e9: map_key_clear(KEY_VOLUMEUP); break;
624 case 0x0ea: map_key_clear(KEY_VOLUMEDOWN); break;
625
626 case 0x182: map_key_clear(KEY_BOOKMARKS); break;
627 case 0x183: map_key_clear(KEY_CONFIG); break;
628 case 0x184: map_key_clear(KEY_WORDPROCESSOR); break;
629 case 0x185: map_key_clear(KEY_EDITOR); break;
630 case 0x186: map_key_clear(KEY_SPREADSHEET); break;
631 case 0x187: map_key_clear(KEY_GRAPHICSEDITOR); break;
632 case 0x188: map_key_clear(KEY_PRESENTATION); break;
633 case 0x189: map_key_clear(KEY_DATABASE); break;
634 case 0x18a: map_key_clear(KEY_MAIL); break;
635 case 0x18b: map_key_clear(KEY_NEWS); break;
636 case 0x18c: map_key_clear(KEY_VOICEMAIL); break;
637 case 0x18d: map_key_clear(KEY_ADDRESSBOOK); break;
638 case 0x18e: map_key_clear(KEY_CALENDAR); break;
639 case 0x191: map_key_clear(KEY_FINANCE); break;
640 case 0x192: map_key_clear(KEY_CALC); break;
641 case 0x194: map_key_clear(KEY_FILE); break;
642 case 0x196: map_key_clear(KEY_WWW); break;
643 case 0x19c: map_key_clear(KEY_LOGOFF); break;
644 case 0x19e: map_key_clear(KEY_COFFEE); break;
645 case 0x1a6: map_key_clear(KEY_HELP); break;
646 case 0x1a7: map_key_clear(KEY_DOCUMENTS); break;
647 case 0x1ab: map_key_clear(KEY_SPELLCHECK); break;
648 case 0x1b6: map_key_clear(KEY_MEDIA); break;
649 case 0x1b7: map_key_clear(KEY_SOUND); break;
650 case 0x1bc: map_key_clear(KEY_MESSENGER); break;
651 case 0x1bd: map_key_clear(KEY_INFO); break;
652 case 0x201: map_key_clear(KEY_NEW); break;
653 case 0x202: map_key_clear(KEY_OPEN); break;
654 case 0x203: map_key_clear(KEY_CLOSE); break;
655 case 0x204: map_key_clear(KEY_EXIT); break;
656 case 0x207: map_key_clear(KEY_SAVE); break;
657 case 0x208: map_key_clear(KEY_PRINT); break;
658 case 0x209: map_key_clear(KEY_PROPS); break;
659 case 0x21a: map_key_clear(KEY_UNDO); break;
660 case 0x21b: map_key_clear(KEY_COPY); break;
661 case 0x21c: map_key_clear(KEY_CUT); break;
662 case 0x21d: map_key_clear(KEY_PASTE); break;
663 case 0x21f: map_key_clear(KEY_FIND); break;
664 case 0x221: map_key_clear(KEY_SEARCH); break;
665 case 0x222: map_key_clear(KEY_GOTO); break;
666 case 0x223: map_key_clear(KEY_HOMEPAGE); break;
667 case 0x224: map_key_clear(KEY_BACK); break;
668 case 0x225: map_key_clear(KEY_FORWARD); break;
669 case 0x226: map_key_clear(KEY_STOP); break;
670 case 0x227: map_key_clear(KEY_REFRESH); break;
671 case 0x22a: map_key_clear(KEY_BOOKMARKS); break;
672 case 0x22d: map_key_clear(KEY_ZOOMIN); break;
673 case 0x22e: map_key_clear(KEY_ZOOMOUT); break;
674 case 0x22f: map_key_clear(KEY_ZOOMRESET); break;
675 case 0x233: map_key_clear(KEY_SCROLLUP); break;
676 case 0x234: map_key_clear(KEY_SCROLLDOWN); break;
677 case 0x238: map_rel(REL_HWHEEL); break;
678 case 0x25f: map_key_clear(KEY_CANCEL); break;
679 case 0x279: map_key_clear(KEY_REDO); break;
680
681 case 0x289: map_key_clear(KEY_REPLY); break;
682 case 0x28b: map_key_clear(KEY_FORWARDMAIL); break;
683 case 0x28c: map_key_clear(KEY_SEND); break;
684
685 default: goto ignore;
686 } 318 }
687 break; 319 break;
688 320
689 case HID_UP_HPVENDOR: /* Reported on a Dutch layout HP5308 */ 321 case 0x3c: /* Invert */
690 322 map_key_clear(BTN_TOOL_RUBBER);
691 set_bit(EV_REP, input->evbit);
692 switch (usage->hid & HID_USAGE) {
693 case 0x021: map_key_clear(KEY_PRINT); break;
694 case 0x070: map_key_clear(KEY_HP); break;
695 case 0x071: map_key_clear(KEY_CAMERA); break;
696 case 0x072: map_key_clear(KEY_SOUND); break;
697 case 0x073: map_key_clear(KEY_QUESTION); break;
698 case 0x080: map_key_clear(KEY_EMAIL); break;
699 case 0x081: map_key_clear(KEY_CHAT); break;
700 case 0x082: map_key_clear(KEY_SEARCH); break;
701 case 0x083: map_key_clear(KEY_CONNECT); break;
702 case 0x084: map_key_clear(KEY_FINANCE); break;
703 case 0x085: map_key_clear(KEY_SPORT); break;
704 case 0x086: map_key_clear(KEY_SHOP); break;
705 default: goto ignore;
706 }
707 break; 323 break;
708 324
709 case HID_UP_MSVENDOR: 325 case 0x33: /* Touch */
710 326 case 0x42: /* TipSwitch */
711 goto ignore; 327 case 0x43: /* TipSwitch2 */
712 328 device->quirks &= ~HID_QUIRK_NOTOUCH;
713 case HID_UP_CUSTOM: /* Reported on Logitech and Apple USB keyboards */ 329 map_key_clear(BTN_TOUCH);
714 330 break;
715 set_bit(EV_REP, input->evbit);
716 switch(usage->hid & HID_USAGE) {
717 case 0x003:
718 /* The fn key on Apple USB keyboards */
719 map_key_clear(KEY_FN);
720 hidinput_apple_setup(input);
721 break;
722 331
723 default: goto ignore; 332 case 0x44: /* BarrelSwitch */
724 } 333 map_key_clear(BTN_STYLUS);
725 break; 334 break;
726 335
727 case HID_UP_LOGIVENDOR: 336 default: goto unknown;
337 }
338 break;
339
340 case HID_UP_CONSUMER: /* USB HUT v1.1, pages 56-62 */
341 switch (usage->hid & HID_USAGE) {
342 case 0x000: goto ignore;
343 case 0x034: map_key_clear(KEY_SLEEP); break;
344 case 0x036: map_key_clear(BTN_MISC); break;
345
346 case 0x040: map_key_clear(KEY_MENU); break;
347 case 0x045: map_key_clear(KEY_RADIO); break;
348
349 case 0x083: map_key_clear(KEY_LAST); break;
350 case 0x088: map_key_clear(KEY_PC); break;
351 case 0x089: map_key_clear(KEY_TV); break;
352 case 0x08a: map_key_clear(KEY_WWW); break;
353 case 0x08b: map_key_clear(KEY_DVD); break;
354 case 0x08c: map_key_clear(KEY_PHONE); break;
355 case 0x08d: map_key_clear(KEY_PROGRAM); break;
356 case 0x08e: map_key_clear(KEY_VIDEOPHONE); break;
357 case 0x08f: map_key_clear(KEY_GAMES); break;
358 case 0x090: map_key_clear(KEY_MEMO); break;
359 case 0x091: map_key_clear(KEY_CD); break;
360 case 0x092: map_key_clear(KEY_VCR); break;
361 case 0x093: map_key_clear(KEY_TUNER); break;
362 case 0x094: map_key_clear(KEY_EXIT); break;
363 case 0x095: map_key_clear(KEY_HELP); break;
364 case 0x096: map_key_clear(KEY_TAPE); break;
365 case 0x097: map_key_clear(KEY_TV2); break;
366 case 0x098: map_key_clear(KEY_SAT); break;
367 case 0x09a: map_key_clear(KEY_PVR); break;
368
369 case 0x09c: map_key_clear(KEY_CHANNELUP); break;
370 case 0x09d: map_key_clear(KEY_CHANNELDOWN); break;
371 case 0x0a0: map_key_clear(KEY_VCR2); break;
372
373 case 0x0b0: map_key_clear(KEY_PLAY); break;
374 case 0x0b1: map_key_clear(KEY_PAUSE); break;
375 case 0x0b2: map_key_clear(KEY_RECORD); break;
376 case 0x0b3: map_key_clear(KEY_FASTFORWARD); break;
377 case 0x0b4: map_key_clear(KEY_REWIND); break;
378 case 0x0b5: map_key_clear(KEY_NEXTSONG); break;
379 case 0x0b6: map_key_clear(KEY_PREVIOUSSONG); break;
380 case 0x0b7: map_key_clear(KEY_STOPCD); break;
381 case 0x0b8: map_key_clear(KEY_EJECTCD); break;
382 case 0x0bc: map_key_clear(KEY_MEDIA_REPEAT); break;
383
384 case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break;
385 case 0x0e0: map_abs_clear(ABS_VOLUME); break;
386 case 0x0e2: map_key_clear(KEY_MUTE); break;
387 case 0x0e5: map_key_clear(KEY_BASSBOOST); break;
388 case 0x0e9: map_key_clear(KEY_VOLUMEUP); break;
389 case 0x0ea: map_key_clear(KEY_VOLUMEDOWN); break;
390
391 case 0x182: map_key_clear(KEY_BOOKMARKS); break;
392 case 0x183: map_key_clear(KEY_CONFIG); break;
393 case 0x184: map_key_clear(KEY_WORDPROCESSOR); break;
394 case 0x185: map_key_clear(KEY_EDITOR); break;
395 case 0x186: map_key_clear(KEY_SPREADSHEET); break;
396 case 0x187: map_key_clear(KEY_GRAPHICSEDITOR); break;
397 case 0x188: map_key_clear(KEY_PRESENTATION); break;
398 case 0x189: map_key_clear(KEY_DATABASE); break;
399 case 0x18a: map_key_clear(KEY_MAIL); break;
400 case 0x18b: map_key_clear(KEY_NEWS); break;
401 case 0x18c: map_key_clear(KEY_VOICEMAIL); break;
402 case 0x18d: map_key_clear(KEY_ADDRESSBOOK); break;
403 case 0x18e: map_key_clear(KEY_CALENDAR); break;
404 case 0x191: map_key_clear(KEY_FINANCE); break;
405 case 0x192: map_key_clear(KEY_CALC); break;
406 case 0x194: map_key_clear(KEY_FILE); break;
407 case 0x196: map_key_clear(KEY_WWW); break;
408 case 0x19c: map_key_clear(KEY_LOGOFF); break;
409 case 0x19e: map_key_clear(KEY_COFFEE); break;
410 case 0x1a6: map_key_clear(KEY_HELP); break;
411 case 0x1a7: map_key_clear(KEY_DOCUMENTS); break;
412 case 0x1ab: map_key_clear(KEY_SPELLCHECK); break;
413 case 0x1b6: map_key_clear(KEY_MEDIA); break;
414 case 0x1b7: map_key_clear(KEY_SOUND); break;
415 case 0x1bc: map_key_clear(KEY_MESSENGER); break;
416 case 0x1bd: map_key_clear(KEY_INFO); break;
417 case 0x201: map_key_clear(KEY_NEW); break;
418 case 0x202: map_key_clear(KEY_OPEN); break;
419 case 0x203: map_key_clear(KEY_CLOSE); break;
420 case 0x204: map_key_clear(KEY_EXIT); break;
421 case 0x207: map_key_clear(KEY_SAVE); break;
422 case 0x208: map_key_clear(KEY_PRINT); break;
423 case 0x209: map_key_clear(KEY_PROPS); break;
424 case 0x21a: map_key_clear(KEY_UNDO); break;
425 case 0x21b: map_key_clear(KEY_COPY); break;
426 case 0x21c: map_key_clear(KEY_CUT); break;
427 case 0x21d: map_key_clear(KEY_PASTE); break;
428 case 0x21f: map_key_clear(KEY_FIND); break;
429 case 0x221: map_key_clear(KEY_SEARCH); break;
430 case 0x222: map_key_clear(KEY_GOTO); break;
431 case 0x223: map_key_clear(KEY_HOMEPAGE); break;
432 case 0x224: map_key_clear(KEY_BACK); break;
433 case 0x225: map_key_clear(KEY_FORWARD); break;
434 case 0x226: map_key_clear(KEY_STOP); break;
435 case 0x227: map_key_clear(KEY_REFRESH); break;
436 case 0x22a: map_key_clear(KEY_BOOKMARKS); break;
437 case 0x22d: map_key_clear(KEY_ZOOMIN); break;
438 case 0x22e: map_key_clear(KEY_ZOOMOUT); break;
439 case 0x22f: map_key_clear(KEY_ZOOMRESET); break;
440 case 0x233: map_key_clear(KEY_SCROLLUP); break;
441 case 0x234: map_key_clear(KEY_SCROLLDOWN); break;
442 case 0x238: map_rel(REL_HWHEEL); break;
443 case 0x25f: map_key_clear(KEY_CANCEL); break;
444 case 0x279: map_key_clear(KEY_REDO); break;
445
446 case 0x289: map_key_clear(KEY_REPLY); break;
447 case 0x28b: map_key_clear(KEY_FORWARDMAIL); break;
448 case 0x28c: map_key_clear(KEY_SEND); break;
449
450 default: goto ignore;
451 }
452 break;
453
454 case HID_UP_HPVENDOR: /* Reported on a Dutch layout HP5308 */
455 set_bit(EV_REP, input->evbit);
456 switch (usage->hid & HID_USAGE) {
457 case 0x021: map_key_clear(KEY_PRINT); break;
458 case 0x070: map_key_clear(KEY_HP); break;
459 case 0x071: map_key_clear(KEY_CAMERA); break;
460 case 0x072: map_key_clear(KEY_SOUND); break;
461 case 0x073: map_key_clear(KEY_QUESTION); break;
462 case 0x080: map_key_clear(KEY_EMAIL); break;
463 case 0x081: map_key_clear(KEY_CHAT); break;
464 case 0x082: map_key_clear(KEY_SEARCH); break;
465 case 0x083: map_key_clear(KEY_CONNECT); break;
466 case 0x084: map_key_clear(KEY_FINANCE); break;
467 case 0x085: map_key_clear(KEY_SPORT); break;
468 case 0x086: map_key_clear(KEY_SHOP); break;
469 default: goto ignore;
470 }
471 break;
728 472
729 goto ignore; 473 case HID_UP_MSVENDOR:
730 474 goto ignore;
731 case HID_UP_PID:
732 475
733 switch(usage->hid & HID_USAGE) { 476 case HID_UP_CUSTOM: /* Reported on Logitech and Apple USB keyboards */
734 case 0xa4: map_key_clear(BTN_DEAD); break; 477 set_bit(EV_REP, input->evbit);
735 default: goto ignore; 478 goto ignore;
736 }
737 break;
738 479
739 default: 480 case HID_UP_LOGIVENDOR:
740 unknown: 481 goto ignore;
741 if (field->report_size == 1) { 482
742 if (field->report->type == HID_OUTPUT_REPORT) { 483 case HID_UP_PID:
743 map_led(LED_MISC); 484 switch (usage->hid & HID_USAGE) {
744 break; 485 case 0xa4: map_key_clear(BTN_DEAD); break;
745 } 486 default: goto ignore;
746 map_key(BTN_MISC); 487 }
747 break; 488 break;
748 } 489
749 if (field->flags & HID_MAIN_ITEM_RELATIVE) { 490 default:
750 map_rel(REL_MISC); 491 unknown:
492 if (field->report_size == 1) {
493 if (field->report->type == HID_OUTPUT_REPORT) {
494 map_led(LED_MISC);
751 break; 495 break;
752 } 496 }
753 map_abs(ABS_MISC); 497 map_key(BTN_MISC);
498 break;
499 }
500 if (field->flags & HID_MAIN_ITEM_RELATIVE) {
501 map_rel(REL_MISC);
754 break; 502 break;
503 }
504 map_abs(ABS_MISC);
505 break;
755 } 506 }
756 507
757mapped: 508mapped:
758 if (device->quirks & HID_QUIRK_MIGHTYMOUSE) { 509 if (device->driver->input_mapped && device->driver->input_mapped(device,
759 if (usage->hid == HID_GD_Z) 510 hidinput, field, usage, &bit, &max) < 0)
760 map_rel(REL_HWHEEL);
761 else if (usage->code == BTN_1)
762 map_key(BTN_2);
763 else if (usage->code == BTN_2)
764 map_key(BTN_1);
765 }
766
767 if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5 |
768 HID_QUIRK_2WHEEL_MOUSE_HACK_B8)) && (usage->type == EV_REL) &&
769 (usage->code == REL_WHEEL))
770 set_bit(REL_HWHEEL, bit);
771
772 if (((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005))
773 || ((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007)))
774 goto ignore; 511 goto ignore;
775 512
776 if ((device->quirks & HID_QUIRK_BAD_RELATIVE_KEYS) &&
777 usage->type == EV_KEY && (field->flags & HID_MAIN_ITEM_RELATIVE))
778 field->flags &= ~HID_MAIN_ITEM_RELATIVE;
779
780 set_bit(usage->type, input->evbit); 513 set_bit(usage->type, input->evbit);
781 514
782 if (device->quirks & HID_QUIRK_DUPLICATE_USAGES &&
783 (usage->type == EV_KEY ||
784 usage->type == EV_REL ||
785 usage->type == EV_ABS))
786 clear_bit(usage->code, bit);
787
788 while (usage->code <= max && test_and_set_bit(usage->code, bit)) 515 while (usage->code <= max && test_and_set_bit(usage->code, bit))
789 usage->code = find_next_zero_bit(bit, max + 1, usage->code); 516 usage->code = find_next_zero_bit(bit, max + 1, usage->code);
790 517
@@ -858,10 +585,6 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
858 if (!usage->type) 585 if (!usage->type)
859 return; 586 return;
860 587
861 /* handle input events for quirky devices */
862 if (hidinput_event_quirks(hid, field, usage, value))
863 return;
864
865 if (usage->hat_min < usage->hat_max || usage->hat_dir) { 588 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
866 int hat_dir = usage->hat_dir; 589 int hat_dir = usage->hat_dir;
867 if (!hat_dir) 590 if (!hat_dir)
@@ -961,14 +684,14 @@ static int hidinput_open(struct input_dev *dev)
961{ 684{
962 struct hid_device *hid = input_get_drvdata(dev); 685 struct hid_device *hid = input_get_drvdata(dev);
963 686
964 return hid->hid_open(hid); 687 return hid->ll_driver->open(hid);
965} 688}
966 689
967static void hidinput_close(struct input_dev *dev) 690static void hidinput_close(struct input_dev *dev)
968{ 691{
969 struct hid_device *hid = input_get_drvdata(dev); 692 struct hid_device *hid = input_get_drvdata(dev);
970 693
971 hid->hid_close(hid); 694 hid->ll_driver->close(hid);
972} 695}
973 696
974/* 697/*
@@ -977,7 +700,7 @@ static void hidinput_close(struct input_dev *dev)
977 * Read all reports and initialize the absolute field values. 700 * Read all reports and initialize the absolute field values.
978 */ 701 */
979 702
980int hidinput_connect(struct hid_device *hid) 703int hidinput_connect(struct hid_device *hid, unsigned int force)
981{ 704{
982 struct hid_report *report; 705 struct hid_report *report;
983 struct hid_input *hidinput = NULL; 706 struct hid_input *hidinput = NULL;
@@ -985,19 +708,20 @@ int hidinput_connect(struct hid_device *hid)
985 int i, j, k; 708 int i, j, k;
986 int max_report_type = HID_OUTPUT_REPORT; 709 int max_report_type = HID_OUTPUT_REPORT;
987 710
988 if (hid->quirks & HID_QUIRK_IGNORE_HIDINPUT)
989 return -1;
990
991 INIT_LIST_HEAD(&hid->inputs); 711 INIT_LIST_HEAD(&hid->inputs);
992 712
993 for (i = 0; i < hid->maxcollection; i++) 713 if (!force) {
994 if (hid->collection[i].type == HID_COLLECTION_APPLICATION || 714 for (i = 0; i < hid->maxcollection; i++) {
995 hid->collection[i].type == HID_COLLECTION_PHYSICAL) 715 struct hid_collection *col = &hid->collection[i];
996 if (IS_INPUT_APPLICATION(hid->collection[i].usage)) 716 if (col->type == HID_COLLECTION_APPLICATION ||
997 break; 717 col->type == HID_COLLECTION_PHYSICAL)
718 if (IS_INPUT_APPLICATION(col->usage))
719 break;
720 }
998 721
999 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDINPUT) == 0) 722 if (i == hid->maxcollection)
1000 return -1; 723 return -1;
724 }
1001 725
1002 if (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) 726 if (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS)
1003 max_report_type = HID_INPUT_REPORT; 727 max_report_type = HID_INPUT_REPORT;
@@ -1019,7 +743,8 @@ int hidinput_connect(struct hid_device *hid)
1019 } 743 }
1020 744
1021 input_set_drvdata(input_dev, hid); 745 input_set_drvdata(input_dev, hid);
1022 input_dev->event = hid->hidinput_input_event; 746 input_dev->event =
747 hid->ll_driver->hidinput_input_event;
1023 input_dev->open = hidinput_open; 748 input_dev->open = hidinput_open;
1024 input_dev->close = hidinput_close; 749 input_dev->close = hidinput_close;
1025 input_dev->setkeycode = hidinput_setkeycode; 750 input_dev->setkeycode = hidinput_setkeycode;
@@ -1032,7 +757,7 @@ int hidinput_connect(struct hid_device *hid)
1032 input_dev->id.vendor = hid->vendor; 757 input_dev->id.vendor = hid->vendor;
1033 input_dev->id.product = hid->product; 758 input_dev->id.product = hid->product;
1034 input_dev->id.version = hid->version; 759 input_dev->id.version = hid->version;
1035 input_dev->dev.parent = hid->dev; 760 input_dev->dev.parent = hid->dev.parent;
1036 hidinput->input = input_dev; 761 hidinput->input = input_dev;
1037 list_add_tail(&hidinput->list, &hid->inputs); 762 list_add_tail(&hidinput->list, &hid->inputs);
1038 } 763 }
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
new file mode 100644
index 000000000000..406d8c82abf1
--- /dev/null
+++ b/drivers/hid/hid-lg.c
@@ -0,0 +1,342 @@
1/*
2 * HID driver for some logitech "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#include "hid-lg.h"
25
26#define LG_RDESC 0x001
27#define LG_BAD_RELATIVE_KEYS 0x002
28#define LG_DUPLICATE_USAGES 0x004
29#define LG_RESET_LEDS 0x008
30#define LG_EXPANDED_KEYMAP 0x010
31#define LG_IGNORE_DOUBLED_WHEEL 0x020
32#define LG_WIRELESS 0x040
33#define LG_INVERT_HWHEEL 0x080
34#define LG_NOGET 0x100
35#define LG_FF 0x200
36#define LG_FF2 0x400
37
38/*
39 * Certain Logitech keyboards send in report #3 keys which are far
40 * above the logical maximum described in descriptor. This extends
41 * the original value of 0x28c of logical maximum to 0x104d
42 */
43static void lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
44 unsigned int rsize)
45{
46 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
47
48 if ((quirks & LG_RDESC) && rsize >= 90 && rdesc[83] == 0x26 &&
49 rdesc[84] == 0x8c && rdesc[85] == 0x02) {
50 dev_info(&hdev->dev, "fixing up Logitech keyboard report "
51 "descriptor\n");
52 rdesc[84] = rdesc[89] = 0x4d;
53 rdesc[85] = rdesc[90] = 0x10;
54 }
55}
56
57#define lg_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
58 EV_KEY, (c))
59
60static int lg_ultrax_remote_mapping(struct hid_input *hi,
61 struct hid_usage *usage, unsigned long **bit, int *max)
62{
63 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
64 return 0;
65
66 set_bit(EV_REP, hi->input->evbit);
67 switch (usage->hid & HID_USAGE) {
68 /* Reported on Logitech Ultra X Media Remote */
69 case 0x004: lg_map_key_clear(KEY_AGAIN); break;
70 case 0x00d: lg_map_key_clear(KEY_HOME); break;
71 case 0x024: lg_map_key_clear(KEY_SHUFFLE); break;
72 case 0x025: lg_map_key_clear(KEY_TV); break;
73 case 0x026: lg_map_key_clear(KEY_MENU); break;
74 case 0x031: lg_map_key_clear(KEY_AUDIO); break;
75 case 0x032: lg_map_key_clear(KEY_TEXT); break;
76 case 0x033: lg_map_key_clear(KEY_LAST); break;
77 case 0x047: lg_map_key_clear(KEY_MP3); break;
78 case 0x048: lg_map_key_clear(KEY_DVD); break;
79 case 0x049: lg_map_key_clear(KEY_MEDIA); break;
80 case 0x04a: lg_map_key_clear(KEY_VIDEO); break;
81 case 0x04b: lg_map_key_clear(KEY_ANGLE); break;
82 case 0x04c: lg_map_key_clear(KEY_LANGUAGE); break;
83 case 0x04d: lg_map_key_clear(KEY_SUBTITLE); break;
84 case 0x051: lg_map_key_clear(KEY_RED); break;
85 case 0x052: lg_map_key_clear(KEY_CLOSE); break;
86
87 default:
88 return 0;
89 }
90 return 1;
91}
92
93static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage,
94 unsigned long **bit, int *max)
95{
96 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
97 return 0;
98
99 switch (usage->hid & HID_USAGE) {
100 case 0x1001: lg_map_key_clear(KEY_MESSENGER); break;
101 case 0x1003: lg_map_key_clear(KEY_SOUND); break;
102 case 0x1004: lg_map_key_clear(KEY_VIDEO); break;
103 case 0x1005: lg_map_key_clear(KEY_AUDIO); break;
104 case 0x100a: lg_map_key_clear(KEY_DOCUMENTS); break;
105 case 0x1011: lg_map_key_clear(KEY_PREVIOUSSONG); break;
106 case 0x1012: lg_map_key_clear(KEY_NEXTSONG); break;
107 case 0x1013: lg_map_key_clear(KEY_CAMERA); break;
108 case 0x1014: lg_map_key_clear(KEY_MESSENGER); break;
109 case 0x1015: lg_map_key_clear(KEY_RECORD); break;
110 case 0x1016: lg_map_key_clear(KEY_PLAYER); break;
111 case 0x1017: lg_map_key_clear(KEY_EJECTCD); break;
112 case 0x1018: lg_map_key_clear(KEY_MEDIA); break;
113 case 0x1019: lg_map_key_clear(KEY_PROG1); break;
114 case 0x101a: lg_map_key_clear(KEY_PROG2); break;
115 case 0x101b: lg_map_key_clear(KEY_PROG3); break;
116 case 0x101f: lg_map_key_clear(KEY_ZOOMIN); break;
117 case 0x1020: lg_map_key_clear(KEY_ZOOMOUT); break;
118 case 0x1021: lg_map_key_clear(KEY_ZOOMRESET); break;
119 case 0x1023: lg_map_key_clear(KEY_CLOSE); break;
120 case 0x1027: lg_map_key_clear(KEY_MENU); break;
121 /* this one is marked as 'Rotate' */
122 case 0x1028: lg_map_key_clear(KEY_ANGLE); break;
123 case 0x1029: lg_map_key_clear(KEY_SHUFFLE); break;
124 case 0x102a: lg_map_key_clear(KEY_BACK); break;
125 case 0x102b: lg_map_key_clear(KEY_CYCLEWINDOWS); break;
126 case 0x1041: lg_map_key_clear(KEY_BATTERY); break;
127 case 0x1042: lg_map_key_clear(KEY_WORDPROCESSOR); break;
128 case 0x1043: lg_map_key_clear(KEY_SPREADSHEET); break;
129 case 0x1044: lg_map_key_clear(KEY_PRESENTATION); break;
130 case 0x1045: lg_map_key_clear(KEY_UNDO); break;
131 case 0x1046: lg_map_key_clear(KEY_REDO); break;
132 case 0x1047: lg_map_key_clear(KEY_PRINT); break;
133 case 0x1048: lg_map_key_clear(KEY_SAVE); break;
134 case 0x1049: lg_map_key_clear(KEY_PROG1); break;
135 case 0x104a: lg_map_key_clear(KEY_PROG2); break;
136 case 0x104b: lg_map_key_clear(KEY_PROG3); break;
137 case 0x104c: lg_map_key_clear(KEY_PROG4); break;
138
139 default:
140 return 0;
141 }
142 return 1;
143}
144
145static int lg_input_mapping(struct hid_device *hdev, struct hid_input *hi,
146 struct hid_field *field, struct hid_usage *usage,
147 unsigned long **bit, int *max)
148{
149 /* extended mapping for certain Logitech hardware (Logitech cordless
150 desktop LX500) */
151 static const u8 e_keymap[] = {
152 0,216, 0,213,175,156, 0, 0, 0, 0,
153 144, 0, 0, 0, 0, 0, 0, 0, 0,212,
154 174,167,152,161,112, 0, 0, 0,154, 0,
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 0, 0, 0, 0,183,184,185,186,187,
159 188,189,190,191,192,193,194, 0, 0, 0
160 };
161 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
162 unsigned int hid = usage->hid;
163
164 if (hdev->product == USB_DEVICE_ID_LOGITECH_RECEIVER &&
165 lg_ultrax_remote_mapping(hi, usage, bit, max))
166 return 1;
167
168 if ((quirks & LG_WIRELESS) && lg_wireless_mapping(hi, usage, bit, max))
169 return 1;
170
171 if ((hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
172 return 0;
173
174 hid &= HID_USAGE;
175
176 /* Special handling for Logitech Cordless Desktop */
177 if (field->application == HID_GD_MOUSE) {
178 if ((quirks & LG_IGNORE_DOUBLED_WHEEL) &&
179 (hid == 7 || hid == 8))
180 return -1;
181 } else {
182 if ((quirks & LG_EXPANDED_KEYMAP) &&
183 hid < ARRAY_SIZE(e_keymap) &&
184 e_keymap[hid] != 0) {
185 hid_map_usage(hi, usage, bit, max, EV_KEY,
186 e_keymap[hid]);
187 return 1;
188 }
189 }
190
191 return 0;
192}
193
194static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi,
195 struct hid_field *field, struct hid_usage *usage,
196 unsigned long **bit, int *max)
197{
198 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
199
200 if ((quirks & LG_BAD_RELATIVE_KEYS) && usage->type == EV_KEY &&
201 (field->flags & HID_MAIN_ITEM_RELATIVE))
202 field->flags &= ~HID_MAIN_ITEM_RELATIVE;
203
204 if ((quirks & LG_DUPLICATE_USAGES) && (usage->type == EV_KEY ||
205 usage->type == EV_REL || usage->type == EV_ABS))
206 clear_bit(usage->code, *bit);
207
208 return 0;
209}
210
211static int lg_event(struct hid_device *hdev, struct hid_field *field,
212 struct hid_usage *usage, __s32 value)
213{
214 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
215
216 if ((quirks & LG_INVERT_HWHEEL) && usage->code == REL_HWHEEL) {
217 input_event(field->hidinput->input, usage->type, usage->code,
218 -value);
219 return 1;
220 }
221
222 return 0;
223}
224
225static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
226{
227 unsigned long quirks = id->driver_data;
228 unsigned int connect_mask = HID_CONNECT_DEFAULT;
229 int ret;
230
231 hid_set_drvdata(hdev, (void *)quirks);
232
233 if (quirks & LG_NOGET)
234 hdev->quirks |= HID_QUIRK_NOGET;
235
236 ret = hid_parse(hdev);
237 if (ret) {
238 dev_err(&hdev->dev, "parse failed\n");
239 goto err_free;
240 }
241
242 if (quirks & (LG_FF | LG_FF2))
243 connect_mask &= ~HID_CONNECT_FF;
244
245 ret = hid_hw_start(hdev, connect_mask);
246 if (ret) {
247 dev_err(&hdev->dev, "hw start failed\n");
248 goto err_free;
249 }
250
251 if (quirks & LG_RESET_LEDS)
252 usbhid_set_leds(hdev);
253
254 if (quirks & LG_FF)
255 lgff_init(hdev);
256 if (quirks & LG_FF2)
257 lg2ff_init(hdev);
258
259 return 0;
260err_free:
261 return ret;
262}
263
264static const struct hid_device_id lg_devices[] = {
265 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
266 .driver_data = LG_RDESC | LG_WIRELESS },
267 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER),
268 .driver_data = LG_RDESC | LG_WIRELESS },
269 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2),
270 .driver_data = LG_RDESC | LG_WIRELESS },
271
272 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER),
273 .driver_data = LG_BAD_RELATIVE_KEYS },
274
275 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP),
276 .driver_data = LG_DUPLICATE_USAGES },
277 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE),
278 .driver_data = LG_DUPLICATE_USAGES },
279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI),
280 .driver_data = LG_DUPLICATE_USAGES },
281
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),
286 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
287 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500),
288 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
289
290 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_LX3),
291 .driver_data = LG_INVERT_HWHEEL },
292 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_V150),
293 .driver_data = LG_INVERT_HWHEEL },
294
295 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D),
296 .driver_data = LG_NOGET },
297 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL),
298 .driver_data = LG_NOGET | LG_FF },
299
300 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD),
301 .driver_data = LG_FF },
302 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2),
303 .driver_data = LG_FF },
304 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D),
305 .driver_data = LG_FF },
306 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO),
307 .driver_data = LG_FF },
308 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL),
309 .driver_data = LG_FF },
310 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2),
311 .driver_data = LG_FF },
312 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2),
313 .driver_data = LG_FF2 },
314 { }
315};
316MODULE_DEVICE_TABLE(hid, lg_devices);
317
318static struct hid_driver lg_driver = {
319 .name = "logitech",
320 .id_table = lg_devices,
321 .report_fixup = lg_report_fixup,
322 .input_mapping = lg_input_mapping,
323 .input_mapped = lg_input_mapped,
324 .event = lg_event,
325 .probe = lg_probe,
326};
327
328static int lg_init(void)
329{
330 return hid_register_driver(&lg_driver);
331}
332
333static void lg_exit(void)
334{
335 hid_unregister_driver(&lg_driver);
336}
337
338module_init(lg_init);
339module_exit(lg_exit);
340MODULE_LICENSE("GPL");
341
342HID_COMPAT_LOAD_DRIVER(logitech);
diff --git a/drivers/hid/hid-lg.h b/drivers/hid/hid-lg.h
new file mode 100644
index 000000000000..27ae750ca878
--- /dev/null
+++ b/drivers/hid/hid-lg.h
@@ -0,0 +1,18 @@
1#ifndef __HID_LG_H
2#define __HID_LG_H
3
4#include <linux/autoconf.h>
5
6#ifdef CONFIG_LOGITECH_FF
7int lgff_init(struct hid_device *hdev);
8#else
9static inline int lgff_init(struct hid_device *hdev) { return -1; }
10#endif
11
12#ifdef CONFIG_LOGIRUMBLEPAD2_FF
13int lg2ff_init(struct hid_device *hdev);
14#else
15static inline int lg2ff_init(struct hid_device *hdev) { return -1; }
16#endif
17
18#endif
diff --git a/drivers/hid/usbhid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
index d469bd0061c9..4e6dc6e26523 100644
--- a/drivers/hid/usbhid/hid-lg2ff.c
+++ b/drivers/hid/hid-lg2ff.c
@@ -24,7 +24,9 @@
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/hid.h> 26#include <linux/hid.h>
27#include "usbhid.h" 27
28#include "usbhid/usbhid.h"
29#include "hid-lg.h"
28 30
29struct lg2ff_device { 31struct lg2ff_device {
30 struct hid_report *report; 32 struct hid_report *report;
@@ -57,7 +59,7 @@ static int play_effect(struct input_dev *dev, void *data,
57 return 0; 59 return 0;
58} 60}
59 61
60int hid_lg2ff_init(struct hid_device *hid) 62int lg2ff_init(struct hid_device *hid)
61{ 63{
62 struct lg2ff_device *lg2ff; 64 struct lg2ff_device *lg2ff;
63 struct hid_report *report; 65 struct hid_report *report;
@@ -69,18 +71,18 @@ int hid_lg2ff_init(struct hid_device *hid)
69 int error; 71 int error;
70 72
71 if (list_empty(report_list)) { 73 if (list_empty(report_list)) {
72 printk(KERN_ERR "hid-lg2ff: no output report found\n"); 74 dev_err(&hid->dev, "no output report found\n");
73 return -ENODEV; 75 return -ENODEV;
74 } 76 }
75 77
76 report = list_entry(report_list->next, struct hid_report, list); 78 report = list_entry(report_list->next, struct hid_report, list);
77 79
78 if (report->maxfield < 1) { 80 if (report->maxfield < 1) {
79 printk(KERN_ERR "hid-lg2ff: output report is empty\n"); 81 dev_err(&hid->dev, "output report is empty\n");
80 return -ENODEV; 82 return -ENODEV;
81 } 83 }
82 if (report->field[0]->report_count < 7) { 84 if (report->field[0]->report_count < 7) {
83 printk(KERN_ERR "hid-lg2ff: not enough values in the field\n"); 85 dev_err(&hid->dev, "not enough values in the field\n");
84 return -ENODEV; 86 return -ENODEV;
85 } 87 }
86 88
@@ -107,7 +109,7 @@ int hid_lg2ff_init(struct hid_device *hid)
107 109
108 usbhid_submit_report(hid, report, USB_DIR_OUT); 110 usbhid_submit_report(hid, report, USB_DIR_OUT);
109 111
110 printk(KERN_INFO "Force feedback for Logitech Rumblepad 2 by " 112 dev_info(&hid->dev, "Force feedback for Logitech Rumblepad 2 by "
111 "Anssi Hannula <anssi.hannula@gmail.com>\n"); 113 "Anssi Hannula <anssi.hannula@gmail.com>\n");
112 114
113 return 0; 115 return 0;
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/hid-lgff.c
index 4b7ab6a46d93..51aff08e10ce 100644
--- a/drivers/hid/usbhid/hid-lgff.c
+++ b/drivers/hid/hid-lgff.c
@@ -30,7 +30,9 @@
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/usb.h> 31#include <linux/usb.h>
32#include <linux/hid.h> 32#include <linux/hid.h>
33#include "usbhid.h" 33
34#include "usbhid/usbhid.h"
35#include "hid-lg.h"
34 36
35struct dev_type { 37struct dev_type {
36 u16 idVendor; 38 u16 idVendor;
@@ -48,6 +50,12 @@ static const signed short ff_joystick[] = {
48 -1 50 -1
49}; 51};
50 52
53static const signed short ff_wheel[] = {
54 FF_CONSTANT,
55 FF_AUTOCENTER,
56 -1
57};
58
51static const struct dev_type devices[] = { 59static const struct dev_type devices[] = {
52 { 0x046d, 0xc211, ff_rumble }, 60 { 0x046d, 0xc211, ff_rumble },
53 { 0x046d, 0xc219, ff_rumble }, 61 { 0x046d, 0xc219, ff_rumble },
@@ -55,7 +63,7 @@ static const struct dev_type devices[] = {
55 { 0x046d, 0xc286, ff_joystick }, 63 { 0x046d, 0xc286, ff_joystick },
56 { 0x046d, 0xc294, ff_joystick }, 64 { 0x046d, 0xc294, ff_joystick },
57 { 0x046d, 0xc295, ff_joystick }, 65 { 0x046d, 0xc295, ff_joystick },
58 { 0x046d, 0xca03, ff_joystick }, 66 { 0x046d, 0xca03, ff_wheel },
59}; 67};
60 68
61static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 69static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
@@ -100,7 +108,24 @@ static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *ef
100 return 0; 108 return 0;
101} 109}
102 110
103int hid_lgff_init(struct hid_device* hid) 111static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
112{
113 struct hid_device *hid = input_get_drvdata(dev);
114 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
115 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
116 __s32 *value = report->field[0]->value;
117 magnitude = (magnitude >> 12) & 0xf;
118 *value++ = 0xfe;
119 *value++ = 0x0d;
120 *value++ = magnitude; /* clockwise strength */
121 *value++ = magnitude; /* counter-clockwise strength */
122 *value++ = 0x80;
123 *value++ = 0x00;
124 *value = 0x00;
125 usbhid_submit_report(hid, report, USB_DIR_OUT);
126}
127
128int lgff_init(struct hid_device* hid)
104{ 129{
105 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 130 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
106 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 131 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
@@ -145,6 +170,9 @@ int hid_lgff_init(struct hid_device* hid)
145 if (error) 170 if (error)
146 return error; 171 return error;
147 172
173 if ( test_bit(FF_AUTOCENTER, dev->ffbit) )
174 dev->ff->set_autocenter = hid_lgff_set_autocenter;
175
148 printk(KERN_INFO "Force feedback for Logitech force feedback devices by Johann Deneux <johann.deneux@it.uu.se>\n"); 176 printk(KERN_INFO "Force feedback for Logitech force feedback devices by Johann Deneux <johann.deneux@it.uu.se>\n");
149 177
150 return 0; 178 return 0;
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
new file mode 100644
index 000000000000..d718b1607d0f
--- /dev/null
+++ b/drivers/hid/hid-microsoft.c
@@ -0,0 +1,219 @@
1/*
2 * HID driver for some microsoft "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/input.h>
21#include <linux/hid.h>
22#include <linux/module.h>
23
24#include "hid-ids.h"
25
26#define MS_HIDINPUT 0x01
27#define MS_ERGONOMY 0x02
28#define MS_PRESENTER 0x04
29#define MS_RDESC 0x08
30#define MS_NOGET 0x10
31
32/*
33 * Microsoft Wireless Desktop Receiver (Model 1028) has several
34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
35 */
36static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
37 unsigned int rsize)
38{
39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
40
41 if ((quirks & MS_RDESC) && rsize == 571 && rdesc[284] == 0x19 &&
42 rdesc[286] == 0x2a && rdesc[304] == 0x19 &&
43 rdesc[306] == 0x29 && rdesc[352] == 0x1a &&
44 rdesc[355] == 0x2a && rdesc[557] == 0x19 &&
45 rdesc[559] == 0x29) {
46 dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver "
47 "Model 1028 report descriptor\n");
48 rdesc[284] = rdesc[304] = rdesc[557] = 0x35;
49 rdesc[352] = 0x36;
50 rdesc[286] = rdesc[355] = 0x46;
51 rdesc[306] = rdesc[559] = 0x45;
52 }
53}
54
55#define ms_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
56 EV_KEY, (c))
57static int ms_ergonomy_kb_quirk(struct hid_input *hi, struct hid_usage *usage,
58 unsigned long **bit, int *max)
59{
60 struct input_dev *input = hi->input;
61
62 switch (usage->hid & HID_USAGE) {
63 case 0xfd06: ms_map_key_clear(KEY_CHAT); break;
64 case 0xfd07: ms_map_key_clear(KEY_PHONE); break;
65 case 0xff05:
66 set_bit(EV_REP, input->evbit);
67 ms_map_key_clear(KEY_F13);
68 set_bit(KEY_F14, input->keybit);
69 set_bit(KEY_F15, input->keybit);
70 set_bit(KEY_F16, input->keybit);
71 set_bit(KEY_F17, input->keybit);
72 set_bit(KEY_F18, input->keybit);
73 default:
74 return 0;
75 }
76 return 1;
77}
78
79static int ms_presenter_8k_quirk(struct hid_input *hi, struct hid_usage *usage,
80 unsigned long **bit, int *max)
81{
82 set_bit(EV_REP, hi->input->evbit);
83 switch (usage->hid & HID_USAGE) {
84 case 0xfd08: ms_map_key_clear(KEY_FORWARD); break;
85 case 0xfd09: ms_map_key_clear(KEY_BACK); break;
86 case 0xfd0b: ms_map_key_clear(KEY_PLAYPAUSE); break;
87 case 0xfd0e: ms_map_key_clear(KEY_CLOSE); break;
88 case 0xfd0f: ms_map_key_clear(KEY_PLAY); break;
89 default:
90 return 0;
91 }
92 return 1;
93}
94
95static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi,
96 struct hid_field *field, struct hid_usage *usage,
97 unsigned long **bit, int *max)
98{
99 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
100
101 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
102 return 0;
103
104 if (quirks & MS_ERGONOMY) {
105 int ret = ms_ergonomy_kb_quirk(hi, usage, bit, max);
106 if (ret)
107 return ret;
108 }
109
110 if ((quirks & MS_PRESENTER) &&
111 ms_presenter_8k_quirk(hi, usage, bit, max))
112 return 1;
113
114 return 0;
115}
116
117static int ms_event(struct hid_device *hdev, struct hid_field *field,
118 struct hid_usage *usage, __s32 value)
119{
120 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
121
122 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
123 !usage->type)
124 return 0;
125
126 /* Handling MS keyboards special buttons */
127 if (quirks & MS_ERGONOMY && usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
128 struct input_dev *input = field->hidinput->input;
129 static unsigned int last_key = 0;
130 unsigned int key = 0;
131 switch (value) {
132 case 0x01: key = KEY_F14; break;
133 case 0x02: key = KEY_F15; break;
134 case 0x04: key = KEY_F16; break;
135 case 0x08: key = KEY_F17; break;
136 case 0x10: key = KEY_F18; break;
137 }
138 if (key) {
139 input_event(input, usage->type, key, 1);
140 last_key = key;
141 } else
142 input_event(input, usage->type, last_key, 0);
143
144 return 1;
145 }
146
147 return 0;
148}
149
150static int ms_probe(struct hid_device *hdev, const struct hid_device_id *id)
151{
152 unsigned long quirks = id->driver_data;
153 int ret;
154
155 hid_set_drvdata(hdev, (void *)quirks);
156
157 if (quirks & MS_NOGET)
158 hdev->quirks |= HID_QUIRK_NOGET;
159
160 ret = hid_parse(hdev);
161 if (ret) {
162 dev_err(&hdev->dev, "parse failed\n");
163 goto err_free;
164 }
165
166 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | ((quirks & MS_HIDINPUT) ?
167 HID_CONNECT_HIDINPUT_FORCE : 0));
168 if (ret) {
169 dev_err(&hdev->dev, "hw start failed\n");
170 goto err_free;
171 }
172
173 return 0;
174err_free:
175 return ret;
176}
177
178static const struct hid_device_id ms_devices[] = {
179 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV),
180 .driver_data = MS_HIDINPUT },
181 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K),
182 .driver_data = MS_ERGONOMY },
183 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K),
184 .driver_data = MS_ERGONOMY | MS_RDESC },
185 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB),
186 .driver_data = MS_PRESENTER },
187 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0),
188 .driver_data = MS_NOGET },
189
190 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT),
191 .driver_data = MS_PRESENTER },
192 { }
193};
194MODULE_DEVICE_TABLE(hid, ms_devices);
195
196static struct hid_driver ms_driver = {
197 .name = "microsoft",
198 .id_table = ms_devices,
199 .report_fixup = ms_report_fixup,
200 .input_mapping = ms_input_mapping,
201 .event = ms_event,
202 .probe = ms_probe,
203};
204
205static int ms_init(void)
206{
207 return hid_register_driver(&ms_driver);
208}
209
210static void ms_exit(void)
211{
212 hid_unregister_driver(&ms_driver);
213}
214
215module_init(ms_init);
216module_exit(ms_exit);
217MODULE_LICENSE("GPL");
218
219HID_COMPAT_LOAD_DRIVER(microsoft);
diff --git a/drivers/hid/hid-monterey.c b/drivers/hid/hid-monterey.c
new file mode 100644
index 000000000000..f3a85a065f18
--- /dev/null
+++ b/drivers/hid/hid-monterey.c
@@ -0,0 +1,82 @@
1/*
2 * HID driver for some monterey "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 void mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
26 unsigned int rsize)
27{
28 if (rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
29 dev_info(&hdev->dev, "fixing up button/consumer in HID report "
30 "descriptor\n");
31 rdesc[30] = 0x0c;
32 }
33}
34
35#define mr_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
36 EV_KEY, (c))
37static int mr_input_mapping(struct hid_device *hdev, struct hid_input *hi,
38 struct hid_field *field, struct hid_usage *usage,
39 unsigned long **bit, int *max)
40{
41 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
42 return 0;
43
44 switch (usage->hid & HID_USAGE) {
45 case 0x156: mr_map_key_clear(KEY_WORDPROCESSOR); break;
46 case 0x157: mr_map_key_clear(KEY_SPREADSHEET); break;
47 case 0x158: mr_map_key_clear(KEY_PRESENTATION); break;
48 case 0x15c: mr_map_key_clear(KEY_STOP); break;
49 default:
50 return 0;
51 }
52 return 1;
53}
54
55static const struct hid_device_id mr_devices[] = {
56 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
57 { }
58};
59MODULE_DEVICE_TABLE(hid, mr_devices);
60
61static struct hid_driver mr_driver = {
62 .name = "monterey",
63 .id_table = mr_devices,
64 .report_fixup = mr_report_fixup,
65 .input_mapping = mr_input_mapping,
66};
67
68static int mr_init(void)
69{
70 return hid_register_driver(&mr_driver);
71}
72
73static void mr_exit(void)
74{
75 hid_unregister_driver(&mr_driver);
76}
77
78module_init(mr_init);
79module_exit(mr_exit);
80MODULE_LICENSE("GPL");
81
82HID_COMPAT_LOAD_DRIVER(monterey);
diff --git a/drivers/hid/hid-petalynx.c b/drivers/hid/hid-petalynx.c
new file mode 100644
index 000000000000..10945fe12d50
--- /dev/null
+++ b/drivers/hid/hid-petalynx.c
@@ -0,0 +1,122 @@
1/*
2 * HID driver for some petalynx "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
25/* Petalynx Maxter Remote has maximum for consumer page set too low */
26static void pl_report_fixup(struct hid_device *hdev, __u8 *rdesc,
27 unsigned int rsize)
28{
29 if (rsize >= 60 && rdesc[39] == 0x2a && rdesc[40] == 0xf5 &&
30 rdesc[41] == 0x00 && rdesc[59] == 0x26 &&
31 rdesc[60] == 0xf9 && rdesc[61] == 0x00) {
32 dev_info(&hdev->dev, "fixing up Petalynx Maxter Remote report "
33 "descriptor\n");
34 rdesc[60] = 0xfa;
35 rdesc[40] = 0xfa;
36 }
37}
38
39#define pl_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
40 EV_KEY, (c))
41static int pl_input_mapping(struct hid_device *hdev, struct hid_input *hi,
42 struct hid_field *field, struct hid_usage *usage,
43 unsigned long **bit, int *max)
44{
45 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_LOGIVENDOR) {
46 switch (usage->hid & HID_USAGE) {
47 case 0x05a: pl_map_key_clear(KEY_TEXT); break;
48 case 0x05b: pl_map_key_clear(KEY_RED); break;
49 case 0x05c: pl_map_key_clear(KEY_GREEN); break;
50 case 0x05d: pl_map_key_clear(KEY_YELLOW); break;
51 case 0x05e: pl_map_key_clear(KEY_BLUE); break;
52 default:
53 return 0;
54 }
55 return 1;
56 }
57
58 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) {
59 switch (usage->hid & HID_USAGE) {
60 case 0x0f6: pl_map_key_clear(KEY_NEXT); break;
61 case 0x0fa: pl_map_key_clear(KEY_BACK); break;
62 default:
63 return 0;
64 }
65 return 1;
66 }
67
68 return 0;
69}
70
71static int pl_probe(struct hid_device *hdev, const struct hid_device_id *id)
72{
73 int ret;
74
75 hdev->quirks |= HID_QUIRK_NOGET;
76
77 ret = hid_parse(hdev);
78 if (ret) {
79 dev_err(&hdev->dev, "parse failed\n");
80 goto err_free;
81 }
82
83 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
84 if (ret) {
85 dev_err(&hdev->dev, "hw start failed\n");
86 goto err_free;
87 }
88
89 return 0;
90err_free:
91 return ret;
92}
93
94static const struct hid_device_id pl_devices[] = {
95 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
96 { }
97};
98MODULE_DEVICE_TABLE(hid, pl_devices);
99
100static struct hid_driver pl_driver = {
101 .name = "petalynx",
102 .id_table = pl_devices,
103 .report_fixup = pl_report_fixup,
104 .input_mapping = pl_input_mapping,
105 .probe = pl_probe,
106};
107
108static int pl_init(void)
109{
110 return hid_register_driver(&pl_driver);
111}
112
113static void pl_exit(void)
114{
115 hid_unregister_driver(&pl_driver);
116}
117
118module_init(pl_init);
119module_exit(pl_exit);
120MODULE_LICENSE("GPL");
121
122HID_COMPAT_LOAD_DRIVER(petalynx);
diff --git a/drivers/hid/usbhid/hid-plff.c b/drivers/hid/hid-pl.c
index 9eb83cf9d22b..acd815586182 100644
--- a/drivers/hid/usbhid/hid-plff.c
+++ b/drivers/hid/hid-pl.c
@@ -9,7 +9,7 @@
9 * - contains two reports, one for each port (HID_QUIRK_MULTI_INPUT) 9 * - contains two reports, one for each port (HID_QUIRK_MULTI_INPUT)
10 * 10 *
11 * 0e8f:0003 "GreenAsia Inc. USB Joystick " 11 * 0e8f:0003 "GreenAsia Inc. USB Joystick "
12 * - tested with Köng Gaming gamepad 12 * - tested with K??ng Gaming gamepad
13 * 13 *
14 * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com> 14 * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com>
15 */ 15 */
@@ -38,7 +38,11 @@
38#include <linux/input.h> 38#include <linux/input.h>
39#include <linux/usb.h> 39#include <linux/usb.h>
40#include <linux/hid.h> 40#include <linux/hid.h>
41#include "usbhid.h" 41
42#include "hid-ids.h"
43
44#ifdef CONFIG_PANTHERLORD_FF
45#include "usbhid/usbhid.h"
42 46
43struct plff_device { 47struct plff_device {
44 struct hid_report *report; 48 struct hid_report *report;
@@ -66,7 +70,7 @@ static int hid_plff_play(struct input_dev *dev, void *data,
66 return 0; 70 return 0;
67} 71}
68 72
69int hid_plff_init(struct hid_device *hid) 73static int plff_init(struct hid_device *hid)
70{ 74{
71 struct plff_device *plff; 75 struct plff_device *plff;
72 struct hid_report *report; 76 struct hid_report *report;
@@ -86,7 +90,7 @@ int hid_plff_init(struct hid_device *hid)
86 currently unknown. */ 90 currently unknown. */
87 91
88 if (list_empty(report_list)) { 92 if (list_empty(report_list)) {
89 printk(KERN_ERR "hid-plff: no output reports found\n"); 93 dev_err(&hid->dev, "no output reports found\n");
90 return -ENODEV; 94 return -ENODEV;
91 } 95 }
92 96
@@ -95,18 +99,19 @@ int hid_plff_init(struct hid_device *hid)
95 report_ptr = report_ptr->next; 99 report_ptr = report_ptr->next;
96 100
97 if (report_ptr == report_list) { 101 if (report_ptr == report_list) {
98 printk(KERN_ERR "hid-plff: required output report is missing\n"); 102 dev_err(&hid->dev, "required output report is "
103 "missing\n");
99 return -ENODEV; 104 return -ENODEV;
100 } 105 }
101 106
102 report = list_entry(report_ptr, struct hid_report, list); 107 report = list_entry(report_ptr, struct hid_report, list);
103 if (report->maxfield < 1) { 108 if (report->maxfield < 1) {
104 printk(KERN_ERR "hid-plff: no fields in the report\n"); 109 dev_err(&hid->dev, "no fields in the report\n");
105 return -ENODEV; 110 return -ENODEV;
106 } 111 }
107 112
108 if (report->field[0]->report_count < 4) { 113 if (report->field[0]->report_count < 4) {
109 printk(KERN_ERR "hid-plff: not enough values in the field\n"); 114 dev_err(&hid->dev, "not enough values in the field\n");
110 return -ENODEV; 115 return -ENODEV;
111 } 116 }
112 117
@@ -132,8 +137,70 @@ int hid_plff_init(struct hid_device *hid)
132 usbhid_submit_report(hid, plff->report, USB_DIR_OUT); 137 usbhid_submit_report(hid, plff->report, USB_DIR_OUT);
133 } 138 }
134 139
135 printk(KERN_INFO "hid-plff: Force feedback for PantherLord/GreenAsia " 140 dev_info(&hid->dev, "Force feedback for PantherLord/GreenAsia "
136 "devices by Anssi Hannula <anssi.hannula@gmail.com>\n"); 141 "devices by Anssi Hannula <anssi.hannula@gmail.com>\n");
137 142
138 return 0; 143 return 0;
139} 144}
145#else
146static inline int plff_init(struct hid_device *hid)
147{
148 return 0;
149}
150#endif
151
152static int pl_probe(struct hid_device *hdev, const struct hid_device_id *id)
153{
154 int ret;
155
156 if (id->driver_data)
157 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
158
159 ret = hid_parse(hdev);
160 if (ret) {
161 dev_err(&hdev->dev, "parse failed\n");
162 goto err;
163 }
164
165 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
166 if (ret) {
167 dev_err(&hdev->dev, "hw start failed\n");
168 goto err;
169 }
170
171 plff_init(hdev);
172
173 return 0;
174err:
175 return ret;
176}
177
178static const struct hid_device_id pl_devices[] = {
179 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR),
180 .driver_data = 1 }, /* Twin USB Joystick */
181 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003), }, /* GreenAsia Inc. USB Joystick */
182 { }
183};
184MODULE_DEVICE_TABLE(hid, pl_devices);
185
186static struct hid_driver pl_driver = {
187 .name = "pantherlord",
188 .id_table = pl_devices,
189 .probe = pl_probe,
190};
191
192static int pl_init(void)
193{
194 return hid_register_driver(&pl_driver);
195}
196
197static void pl_exit(void)
198{
199 hid_unregister_driver(&pl_driver);
200}
201
202module_init(pl_init);
203module_exit(pl_exit);
204MODULE_LICENSE("GPL");
205
206HID_COMPAT_LOAD_DRIVER(pantherlord);
diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
new file mode 100644
index 000000000000..15f3c0492450
--- /dev/null
+++ b/drivers/hid/hid-samsung.c
@@ -0,0 +1,100 @@
1/*
2 * HID driver for some samsung "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
25/*
26 * Samsung IrDA remote controller (reports as Cypress USB Mouse).
27 *
28 * Vendor specific report #4 has a size of 48 bit,
29 * and therefore is not accepted when inspecting the descriptors.
30 * As a workaround we reinterpret the report as:
31 * Variable type, count 6, size 8 bit, log. maximum 255
32 * The burden to reconstruct the data is moved into user space.
33 */
34static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
35 unsigned int rsize)
36{
37 if (rsize >= 182 && rdesc[175] == 0x25 && rdesc[176] == 0x40 &&
38 rdesc[177] == 0x75 && rdesc[178] == 0x30 &&
39 rdesc[179] == 0x95 && rdesc[180] == 0x01 &&
40 rdesc[182] == 0x40) {
41 dev_info(&hdev->dev, "fixing up Samsung IrDA report "
42 "descriptor\n");
43 rdesc[176] = 0xff;
44 rdesc[178] = 0x08;
45 rdesc[180] = 0x06;
46 rdesc[182] = 0x42;
47 }
48}
49
50static int samsung_probe(struct hid_device *hdev,
51 const struct hid_device_id *id)
52{
53 int ret;
54
55 ret = hid_parse(hdev);
56 if (ret) {
57 dev_err(&hdev->dev, "parse failed\n");
58 goto err_free;
59 }
60
61 ret = hid_hw_start(hdev, (HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT) |
62 HID_CONNECT_HIDDEV_FORCE);
63 if (ret) {
64 dev_err(&hdev->dev, "hw start failed\n");
65 goto err_free;
66 }
67
68 return 0;
69err_free:
70 return ret;
71}
72
73static const struct hid_device_id samsung_devices[] = {
74 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
75 { }
76};
77MODULE_DEVICE_TABLE(hid, samsung_devices);
78
79static struct hid_driver samsung_driver = {
80 .name = "samsung",
81 .id_table = samsung_devices,
82 .report_fixup = samsung_report_fixup,
83 .probe = samsung_probe,
84};
85
86static int samsung_init(void)
87{
88 return hid_register_driver(&samsung_driver);
89}
90
91static void samsung_exit(void)
92{
93 hid_unregister_driver(&samsung_driver);
94}
95
96module_init(samsung_init);
97module_exit(samsung_exit);
98MODULE_LICENSE("GPL");
99
100HID_COMPAT_LOAD_DRIVER(samsung);
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
new file mode 100644
index 000000000000..3af8095a7de1
--- /dev/null
+++ b/drivers/hid/hid-sony.c
@@ -0,0 +1,110 @@
1/*
2 * HID driver for some sony "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#include <linux/usb.h>
23
24#include "hid-ids.h"
25
26/*
27 * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
28 * to "operational". Without this, the ps3 controller will not report any
29 * events.
30 */
31static int sony_set_operational(struct hid_device *hdev)
32{
33 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
34 struct usb_device *dev = interface_to_usbdev(intf);
35 __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
36 int ret;
37 char *buf = kmalloc(18, GFP_KERNEL);
38
39 if (!buf)
40 return -ENOMEM;
41
42 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
43 HID_REQ_GET_REPORT,
44 USB_DIR_IN | USB_TYPE_CLASS |
45 USB_RECIP_INTERFACE,
46 (3 << 8) | 0xf2, ifnum, buf, 17,
47 USB_CTRL_GET_TIMEOUT);
48 if (ret < 0)
49 dev_err(&hdev->dev, "can't set operational mode\n");
50
51 kfree(buf);
52
53 return ret;
54}
55
56static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
57{
58 int ret;
59
60 ret = hid_parse(hdev);
61 if (ret) {
62 dev_err(&hdev->dev, "parse failed\n");
63 goto err_free;
64 }
65
66 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT |
67 HID_CONNECT_HIDDEV_FORCE);
68 if (ret) {
69 dev_err(&hdev->dev, "hw start failed\n");
70 goto err_free;
71 }
72
73 ret = sony_set_operational(hdev);
74 if (ret)
75 goto err_stop;
76
77 return 0;
78err_stop:
79 hid_hw_stop(hdev);
80err_free:
81 return ret;
82}
83
84static const struct hid_device_id sony_devices[] = {
85 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
86 { }
87};
88MODULE_DEVICE_TABLE(hid, sony_devices);
89
90static struct hid_driver sony_driver = {
91 .name = "sony",
92 .id_table = sony_devices,
93 .probe = sony_probe,
94};
95
96static int sony_init(void)
97{
98 return hid_register_driver(&sony_driver);
99}
100
101static void sony_exit(void)
102{
103 hid_unregister_driver(&sony_driver);
104}
105
106module_init(sony_init);
107module_exit(sony_exit);
108MODULE_LICENSE("GPL");
109
110HID_COMPAT_LOAD_DRIVER(sony);
diff --git a/drivers/hid/hid-sunplus.c b/drivers/hid/hid-sunplus.c
new file mode 100644
index 000000000000..5ba68f7dbb78
--- /dev/null
+++ b/drivers/hid/hid-sunplus.c
@@ -0,0 +1,82 @@
1/*
2 * HID driver for some sunplus "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 void sp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
26 unsigned int rsize)
27{
28 if (rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
29 rdesc[106] == 0x03) {
30 dev_info(&hdev->dev, "fixing up Sunplus Wireless Desktop "
31 "report descriptor\n");
32 rdesc[105] = rdesc[110] = 0x03;
33 rdesc[106] = rdesc[111] = 0x21;
34 }
35}
36
37#define sp_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
38 EV_KEY, (c))
39static int sp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
40 struct hid_field *field, struct hid_usage *usage,
41 unsigned long **bit, int *max)
42{
43 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
44 return 0;
45
46 switch (usage->hid & HID_USAGE) {
47 case 0x2003: sp_map_key_clear(KEY_ZOOMIN); break;
48 case 0x2103: sp_map_key_clear(KEY_ZOOMOUT); break;
49 default:
50 return 0;
51 }
52 return 1;
53}
54
55static const struct hid_device_id sp_devices[] = {
56 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
57 { }
58};
59MODULE_DEVICE_TABLE(hid, sp_devices);
60
61static struct hid_driver sp_driver = {
62 .name = "sunplus",
63 .id_table = sp_devices,
64 .report_fixup = sp_report_fixup,
65 .input_mapping = sp_input_mapping,
66};
67
68static int sp_init(void)
69{
70 return hid_register_driver(&sp_driver);
71}
72
73static void sp_exit(void)
74{
75 hid_unregister_driver(&sp_driver);
76}
77
78module_init(sp_init);
79module_exit(sp_exit);
80MODULE_LICENSE("GPL");
81
82HID_COMPAT_LOAD_DRIVER(sunplus);
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/hid-tmff.c
index 144578b1a00c..1b7cba0f7e1f 100644
--- a/drivers/hid/usbhid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -27,23 +27,17 @@
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */ 28 */
29 29
30#include <linux/hid.h>
30#include <linux/input.h> 31#include <linux/input.h>
31
32#undef DEBUG
33#include <linux/usb.h> 32#include <linux/usb.h>
34 33
35#include <linux/hid.h> 34#include "hid-ids.h"
36#include "usbhid.h" 35
36#include "usbhid/usbhid.h"
37 37
38/* Usages for thrustmaster devices I know about */ 38/* Usages for thrustmaster devices I know about */
39#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb) 39#define THRUSTMASTER_USAGE_FF (HID_UP_GENDESK | 0xbb)
40 40
41struct dev_type {
42 u16 idVendor;
43 u16 idProduct;
44 const signed short *ff;
45};
46
47static const signed short ff_rumble[] = { 41static const signed short ff_rumble[] = {
48 FF_RUMBLE, 42 FF_RUMBLE,
49 -1 43 -1
@@ -54,21 +48,13 @@ static const signed short ff_joystick[] = {
54 -1 48 -1
55}; 49};
56 50
57static const struct dev_type devices[] = {
58 { 0x44f, 0xb300, ff_rumble },
59 { 0x44f, 0xb304, ff_rumble },
60 { 0x44f, 0xb651, ff_rumble }, /* FGT Rumble Force Wheel */
61 { 0x44f, 0xb654, ff_joystick }, /* FGT Force Feedback Wheel */
62};
63
64struct tmff_device { 51struct tmff_device {
65 struct hid_report *report; 52 struct hid_report *report;
66 struct hid_field *ff_field; 53 struct hid_field *ff_field;
67}; 54};
68 55
69/* Changes values from 0 to 0xffff into values from minimum to maximum */ 56/* Changes values from 0 to 0xffff into values from minimum to maximum */
70static inline int hid_tmff_scale_u16(unsigned int in, 57static inline int tmff_scale_u16(unsigned int in, int minimum, int maximum)
71 int minimum, int maximum)
72{ 58{
73 int ret; 59 int ret;
74 60
@@ -81,8 +67,7 @@ static inline int hid_tmff_scale_u16(unsigned int in,
81} 67}
82 68
83/* Changes values from -0x80 to 0x7f into values from minimum to maximum */ 69/* Changes values from -0x80 to 0x7f into values from minimum to maximum */
84static inline int hid_tmff_scale_s8(int in, 70static inline int tmff_scale_s8(int in, int minimum, int maximum)
85 int minimum, int maximum)
86{ 71{
87 int ret; 72 int ret;
88 73
@@ -94,7 +79,8 @@ static inline int hid_tmff_scale_s8(int in,
94 return ret; 79 return ret;
95} 80}
96 81
97static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 82static int tmff_play(struct input_dev *dev, void *data,
83 struct ff_effect *effect)
98{ 84{
99 struct hid_device *hid = input_get_drvdata(dev); 85 struct hid_device *hid = input_get_drvdata(dev);
100 struct tmff_device *tmff = data; 86 struct tmff_device *tmff = data;
@@ -104,10 +90,10 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
104 90
105 switch (effect->type) { 91 switch (effect->type) {
106 case FF_CONSTANT: 92 case FF_CONSTANT:
107 x = hid_tmff_scale_s8(effect->u.ramp.start_level, 93 x = tmff_scale_s8(effect->u.ramp.start_level,
108 ff_field->logical_minimum, 94 ff_field->logical_minimum,
109 ff_field->logical_maximum); 95 ff_field->logical_maximum);
110 y = hid_tmff_scale_s8(effect->u.ramp.end_level, 96 y = tmff_scale_s8(effect->u.ramp.end_level,
111 ff_field->logical_minimum, 97 ff_field->logical_minimum,
112 ff_field->logical_maximum); 98 ff_field->logical_maximum);
113 99
@@ -118,10 +104,10 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
118 break; 104 break;
119 105
120 case FF_RUMBLE: 106 case FF_RUMBLE:
121 left = hid_tmff_scale_u16(effect->u.rumble.weak_magnitude, 107 left = tmff_scale_u16(effect->u.rumble.weak_magnitude,
122 ff_field->logical_minimum, 108 ff_field->logical_minimum,
123 ff_field->logical_maximum); 109 ff_field->logical_maximum);
124 right = hid_tmff_scale_u16(effect->u.rumble.strong_magnitude, 110 right = tmff_scale_u16(effect->u.rumble.strong_magnitude,
125 ff_field->logical_minimum, 111 ff_field->logical_minimum,
126 ff_field->logical_maximum); 112 ff_field->logical_maximum);
127 113
@@ -134,14 +120,14 @@ static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *ef
134 return 0; 120 return 0;
135} 121}
136 122
137int hid_tmff_init(struct hid_device *hid) 123static int tmff_init(struct hid_device *hid, const signed short *ff_bits)
138{ 124{
139 struct tmff_device *tmff; 125 struct tmff_device *tmff;
140 struct hid_report *report; 126 struct hid_report *report;
141 struct list_head *report_list; 127 struct list_head *report_list;
142 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 128 struct hid_input *hidinput = list_entry(hid->inputs.next,
129 struct hid_input, list);
143 struct input_dev *input_dev = hidinput->input; 130 struct input_dev *input_dev = hidinput->input;
144 const signed short *ff_bits = ff_joystick;
145 int error; 131 int error;
146 int i; 132 int i;
147 133
@@ -163,63 +149,121 @@ int hid_tmff_init(struct hid_device *hid)
163 switch (field->usage[0].hid) { 149 switch (field->usage[0].hid) {
164 case THRUSTMASTER_USAGE_FF: 150 case THRUSTMASTER_USAGE_FF:
165 if (field->report_count < 2) { 151 if (field->report_count < 2) {
166 warn("ignoring FF field with report_count < 2"); 152 dev_warn(&hid->dev, "ignoring FF field "
153 "with report_count < 2\n");
167 continue; 154 continue;
168 } 155 }
169 156
170 if (field->logical_maximum == field->logical_minimum) { 157 if (field->logical_maximum ==
171 warn("ignoring FF field with logical_maximum == logical_minimum"); 158 field->logical_minimum) {
159 dev_warn(&hid->dev, "ignoring FF field "
160 "with logical_maximum "
161 "== logical_minimum\n");
172 continue; 162 continue;
173 } 163 }
174 164
175 if (tmff->report && tmff->report != report) { 165 if (tmff->report && tmff->report != report) {
176 warn("ignoring FF field in other report"); 166 dev_warn(&hid->dev, "ignoring FF field "
167 "in other report\n");
177 continue; 168 continue;
178 } 169 }
179 170
180 if (tmff->ff_field && tmff->ff_field != field) { 171 if (tmff->ff_field && tmff->ff_field != field) {
181 warn("ignoring duplicate FF field"); 172 dev_warn(&hid->dev, "ignoring "
173 "duplicate FF field\n");
182 continue; 174 continue;
183 } 175 }
184 176
185 tmff->report = report; 177 tmff->report = report;
186 tmff->ff_field = field; 178 tmff->ff_field = field;
187 179
188 for (i = 0; i < ARRAY_SIZE(devices); i++) {
189 if (input_dev->id.vendor == devices[i].idVendor &&
190 input_dev->id.product == devices[i].idProduct) {
191 ff_bits = devices[i].ff;
192 break;
193 }
194 }
195
196 for (i = 0; ff_bits[i] >= 0; i++) 180 for (i = 0; ff_bits[i] >= 0; i++)
197 set_bit(ff_bits[i], input_dev->ffbit); 181 set_bit(ff_bits[i], input_dev->ffbit);
198 182
199 break; 183 break;
200 184
201 default: 185 default:
202 warn("ignoring unknown output usage %08x", field->usage[0].hid); 186 dev_warn(&hid->dev, "ignoring unknown output "
187 "usage %08x\n",
188 field->usage[0].hid);
203 continue; 189 continue;
204 } 190 }
205 } 191 }
206 } 192 }
207 193
208 if (!tmff->report) { 194 if (!tmff->report) {
209 err("cant find FF field in output reports\n"); 195 dev_err(&hid->dev, "can't find FF field in output reports\n");
210 error = -ENODEV; 196 error = -ENODEV;
211 goto fail; 197 goto fail;
212 } 198 }
213 199
214 error = input_ff_create_memless(input_dev, tmff, hid_tmff_play); 200 error = input_ff_create_memless(input_dev, tmff, tmff_play);
215 if (error) 201 if (error)
216 goto fail; 202 goto fail;
217 203
218 info("Force feedback for ThrustMaster devices by Zinx Verituse <zinx@epicsol.org>"); 204 dev_info(&hid->dev, "force feedback for ThrustMaster devices by Zinx "
205 "Verituse <zinx@epicsol.org>");
219 return 0; 206 return 0;
220 207
221 fail: 208fail:
222 kfree(tmff); 209 kfree(tmff);
223 return error; 210 return error;
224} 211}
225 212
213static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id)
214{
215 int ret;
216
217 ret = hid_parse(hdev);
218 if (ret) {
219 dev_err(&hdev->dev, "parse failed\n");
220 goto err;
221 }
222
223 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
224 if (ret) {
225 dev_err(&hdev->dev, "hw start failed\n");
226 goto err;
227 }
228
229 tmff_init(hdev, (void *)id->driver_data);
230
231 return 0;
232err:
233 return ret;
234}
235
236static const struct hid_device_id tm_devices[] = {
237 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300),
238 .driver_data = (unsigned long)ff_rumble },
239 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304),
240 .driver_data = (unsigned long)ff_rumble },
241 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651), /* FGT Rumble Force Wheel */
242 .driver_data = (unsigned long)ff_rumble },
243 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654), /* FGT Force Feedback Wheel */
244 .driver_data = (unsigned long)ff_joystick },
245 { }
246};
247MODULE_DEVICE_TABLE(hid, tm_devices);
248
249static struct hid_driver tm_driver = {
250 .name = "thrustmaster",
251 .id_table = tm_devices,
252 .probe = tm_probe,
253};
254
255static int tm_init(void)
256{
257 return hid_register_driver(&tm_driver);
258}
259
260static void tm_exit(void)
261{
262 hid_unregister_driver(&tm_driver);
263}
264
265module_init(tm_init);
266module_exit(tm_exit);
267MODULE_LICENSE("GPL");
268
269HID_COMPAT_LOAD_DRIVER(thrustmaster);
diff --git a/drivers/hid/usbhid/hid-zpff.c b/drivers/hid/hid-zpff.c
index 5a688274f6a3..ea82f3718b21 100644
--- a/drivers/hid/usbhid/hid-zpff.c
+++ b/drivers/hid/hid-zpff.c
@@ -21,16 +21,19 @@
21 */ 21 */
22 22
23 23
24#include <linux/hid.h>
24#include <linux/input.h> 25#include <linux/input.h>
25#include <linux/usb.h> 26#include <linux/usb.h>
26#include <linux/hid.h> 27
27#include "usbhid.h" 28#include "hid-ids.h"
29
30#include "usbhid/usbhid.h"
28 31
29struct zpff_device { 32struct zpff_device {
30 struct hid_report *report; 33 struct hid_report *report;
31}; 34};
32 35
33static int hid_zpff_play(struct input_dev *dev, void *data, 36static int zpff_play(struct input_dev *dev, void *data,
34 struct ff_effect *effect) 37 struct ff_effect *effect)
35{ 38{
36 struct hid_device *hid = input_get_drvdata(dev); 39 struct hid_device *hid = input_get_drvdata(dev);
@@ -58,7 +61,7 @@ static int hid_zpff_play(struct input_dev *dev, void *data,
58 return 0; 61 return 0;
59} 62}
60 63
61int hid_zpff_init(struct hid_device *hid) 64static int zpff_init(struct hid_device *hid)
62{ 65{
63 struct zpff_device *zpff; 66 struct zpff_device *zpff;
64 struct hid_report *report; 67 struct hid_report *report;
@@ -70,14 +73,14 @@ int hid_zpff_init(struct hid_device *hid)
70 int error; 73 int error;
71 74
72 if (list_empty(report_list)) { 75 if (list_empty(report_list)) {
73 printk(KERN_ERR "hid-zpff: no output report found\n"); 76 dev_err(&hid->dev, "no output report found\n");
74 return -ENODEV; 77 return -ENODEV;
75 } 78 }
76 79
77 report = list_entry(report_list->next, struct hid_report, list); 80 report = list_entry(report_list->next, struct hid_report, list);
78 81
79 if (report->maxfield < 4) { 82 if (report->maxfield < 4) {
80 printk(KERN_ERR "hid-zpff: not enough fields in report\n"); 83 dev_err(&hid->dev, "not enough fields in report\n");
81 return -ENODEV; 84 return -ENODEV;
82 } 85 }
83 86
@@ -87,7 +90,7 @@ int hid_zpff_init(struct hid_device *hid)
87 90
88 set_bit(FF_RUMBLE, dev->ffbit); 91 set_bit(FF_RUMBLE, dev->ffbit);
89 92
90 error = input_ff_create_memless(dev, zpff, hid_zpff_play); 93 error = input_ff_create_memless(dev, zpff, zpff_play);
91 if (error) { 94 if (error) {
92 kfree(zpff); 95 kfree(zpff);
93 return error; 96 return error;
@@ -100,8 +103,60 @@ int hid_zpff_init(struct hid_device *hid)
100 zpff->report->field[3]->value[0] = 0x00; 103 zpff->report->field[3]->value[0] = 0x00;
101 usbhid_submit_report(hid, zpff->report, USB_DIR_OUT); 104 usbhid_submit_report(hid, zpff->report, USB_DIR_OUT);
102 105
103 printk(KERN_INFO "Force feedback for Zeroplus based devices by " 106 dev_info(&hid->dev, "force feedback for Zeroplus based devices by "
104 "Anssi Hannula <anssi.hannula@gmail.com>\n"); 107 "Anssi Hannula <anssi.hannula@gmail.com>\n");
105 108
106 return 0; 109 return 0;
107} 110}
111
112static int zp_probe(struct hid_device *hdev, const struct hid_device_id *id)
113{
114 int ret;
115
116 ret = hid_parse(hdev);
117 if (ret) {
118 dev_err(&hdev->dev, "parse failed\n");
119 goto err;
120 }
121
122 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
123 if (ret) {
124 dev_err(&hdev->dev, "hw start failed\n");
125 goto err;
126 }
127
128 zpff_init(hdev);
129
130 return 0;
131err:
132 return ret;
133}
134
135static const struct hid_device_id zp_devices[] = {
136 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
137 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
138 { }
139};
140MODULE_DEVICE_TABLE(hid, zp_devices);
141
142static struct hid_driver zp_driver = {
143 .name = "zeroplus",
144 .id_table = zp_devices,
145 .probe = zp_probe,
146};
147
148static int zp_init(void)
149{
150 return hid_register_driver(&zp_driver);
151}
152
153static void zp_exit(void)
154{
155 hid_unregister_driver(&zp_driver);
156}
157
158module_init(zp_init);
159module_exit(zp_exit);
160MODULE_LICENSE("GPL");
161
162HID_COMPAT_LOAD_DRIVER(zeroplus);
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index c40f0403edaf..497e0d1dd3c3 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -113,7 +113,7 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
113 if (!dev->hid_output_raw_report) 113 if (!dev->hid_output_raw_report)
114 return -ENODEV; 114 return -ENODEV;
115 115
116 if (count > HID_MIN_BUFFER_SIZE) { 116 if (count > HID_MAX_BUFFER_SIZE) {
117 printk(KERN_WARNING "hidraw: pid %d passed too large report\n", 117 printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
118 task_pid_nr(current)); 118 task_pid_nr(current));
119 return -EINVAL; 119 return -EINVAL;
@@ -181,7 +181,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
181 181
182 dev = hidraw_table[minor]; 182 dev = hidraw_table[minor];
183 if (!dev->open++) 183 if (!dev->open++)
184 dev->hid->hid_open(dev->hid); 184 dev->hid->ll_driver->open(dev->hid);
185 185
186out_unlock: 186out_unlock:
187 spin_unlock(&minors_lock); 187 spin_unlock(&minors_lock);
@@ -207,7 +207,7 @@ static int hidraw_release(struct inode * inode, struct file * file)
207 dev = hidraw_table[minor]; 207 dev = hidraw_table[minor];
208 if (!dev->open--) { 208 if (!dev->open--) {
209 if (list->hidraw->exist) 209 if (list->hidraw->exist)
210 dev->hid->hid_close(dev->hid); 210 dev->hid->ll_driver->close(dev->hid);
211 else 211 else
212 kfree(list->hidraw); 212 kfree(list->hidraw);
213 } 213 }
@@ -367,7 +367,7 @@ void hidraw_disconnect(struct hid_device *hid)
367 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); 367 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
368 368
369 if (hidraw->open) { 369 if (hidraw->open) {
370 hid->hid_close(hid); 370 hid->ll_driver->close(hid);
371 wake_up_interruptible(&hidraw->wait); 371 wake_up_interruptible(&hidraw->wait);
372 } else { 372 } else {
373 kfree(hidraw); 373 kfree(hidraw);
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 18f09104765c..5d9aa95fc3ef 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -24,88 +24,13 @@ config USB_HID
24comment "Input core support is needed for USB HID input layer or HIDBP support" 24comment "Input core support is needed for USB HID input layer or HIDBP support"
25 depends on USB_HID && INPUT=n 25 depends on USB_HID && INPUT=n
26 26
27config USB_HIDINPUT_POWERBOOK
28 bool "Enable support for Apple laptop/aluminum USB special keys"
29 default n
30 depends on USB_HID
31 help
32 Say Y here if you want support for the special keys (Fn, Numlock) on
33 Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB
34 keyboards.
35
36 If unsure, say N.
37
38config HID_FF
39 bool "Force feedback support (EXPERIMENTAL)"
40 depends on USB_HID && EXPERIMENTAL
41 help
42 Say Y here is you want force feedback support for a few HID devices.
43 See below for a list of supported devices.
44
45 See <file:Documentation/input/ff.txt> for a description of the force
46 feedback API.
47
48 If unsure, say N.
49
50config HID_PID 27config HID_PID
51 bool "PID device support" 28 bool "PID device support"
52 depends on HID_FF
53 help 29 help
54 Say Y here if you have a PID-compliant device and wish to enable force 30 Say Y here if you have a PID-compliant device and wish to enable force
55 feedback for it. Microsoft Sidewinder Force Feedback 2 is one of such 31 feedback for it. Microsoft Sidewinder Force Feedback 2 is one of such
56 devices. 32 devices.
57 33
58config LOGITECH_FF
59 bool "Logitech devices support"
60 depends on HID_FF
61 select INPUT_FF_MEMLESS if USB_HID
62 help
63 Say Y here if you have one of these devices:
64 - Logitech WingMan Cordless RumblePad
65 - Logitech WingMan Cordless RumblePad 2
66 - Logitech WingMan Force 3D
67 - Logitech Formula Force EX
68 - Logitech MOMO Force wheel
69
70 and if you want to enable force feedback for them.
71 Note: if you say N here, this device will still be supported, but without
72 force feedback.
73
74config LOGIRUMBLEPAD2_FF
75 bool "Logitech Rumblepad 2 support"
76 depends on HID_FF
77 select INPUT_FF_MEMLESS if USB_HID
78 help
79 Say Y here if you want to enable force feedback support for Logitech
80 Rumblepad 2 devices.
81
82config PANTHERLORD_FF
83 bool "PantherLord/GreenAsia based device support"
84 depends on HID_FF
85 select INPUT_FF_MEMLESS if USB_HID
86 help
87 Say Y here if you have a PantherLord/GreenAsia based game controller
88 or adapter and want to enable force feedback support for it.
89
90config THRUSTMASTER_FF
91 bool "ThrustMaster devices support"
92 depends on HID_FF
93 select INPUT_FF_MEMLESS if USB_HID
94 help
95 Say Y here if you have a THRUSTMASTER FireStore Dual Power 2 or
96 a THRUSTMASTER Ferrari GT Rumble Force or Force Feedback Wheel,
97 and want to enable force feedback support for it.
98 Note: if you say N here, this device will still be supported, but without
99 force feedback.
100
101config ZEROPLUS_FF
102 bool "Zeroplus based game controller support"
103 depends on HID_FF
104 select INPUT_FF_MEMLESS if USB_HID
105 help
106 Say Y here if you have a Zeroplus based game controller and want to
107 enable force feedback for it.
108
109config USB_HIDDEV 34config USB_HIDDEV
110 bool "/dev/hiddev raw HID device support" 35 bool "/dev/hiddev raw HID device support"
111 depends on USB_HID 36 depends on USB_HID
diff --git a/drivers/hid/usbhid/Makefile b/drivers/hid/usbhid/Makefile
index 00a7b7090192..1329ecb37a1c 100644
--- a/drivers/hid/usbhid/Makefile
+++ b/drivers/hid/usbhid/Makefile
@@ -13,24 +13,6 @@ endif
13ifeq ($(CONFIG_HID_PID),y) 13ifeq ($(CONFIG_HID_PID),y)
14 usbhid-objs += hid-pidff.o 14 usbhid-objs += hid-pidff.o
15endif 15endif
16ifeq ($(CONFIG_LOGITECH_FF),y)
17 usbhid-objs += hid-lgff.o
18endif
19ifeq ($(CONFIG_LOGIRUMBLEPAD2_FF),y)
20 usbhid-objs += hid-lg2ff.o
21endif
22ifeq ($(CONFIG_PANTHERLORD_FF),y)
23 usbhid-objs += hid-plff.o
24endif
25ifeq ($(CONFIG_THRUSTMASTER_FF),y)
26 usbhid-objs += hid-tmff.o
27endif
28ifeq ($(CONFIG_ZEROPLUS_FF),y)
29 usbhid-objs += hid-zpff.o
30endif
31ifeq ($(CONFIG_HID_FF),y)
32 usbhid-objs += hid-ff.o
33endif
34 16
35obj-$(CONFIG_USB_HID) += usbhid.o 17obj-$(CONFIG_USB_HID) += usbhid.o
36obj-$(CONFIG_USB_KBD) += usbkbd.o 18obj-$(CONFIG_USB_KBD) += usbkbd.o
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 27fe4d8912cb..1d3b8a394d46 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -44,8 +44,6 @@
44#define DRIVER_DESC "USB HID core driver" 44#define DRIVER_DESC "USB HID core driver"
45#define DRIVER_LICENSE "GPL" 45#define DRIVER_LICENSE "GPL"
46 46
47static char *hid_types[] = {"Device", "Pointer", "Mouse", "Device", "Joystick",
48 "Gamepad", "Keyboard", "Keypad", "Multi-Axis Controller"};
49/* 47/*
50 * Module parameters. 48 * Module parameters.
51 */ 49 */
@@ -61,12 +59,6 @@ MODULE_PARM_DESC(quirks, "Add/modify USB HID quirks by specifying "
61 " quirks=vendorID:productID:quirks" 59 " quirks=vendorID:productID:quirks"
62 " where vendorID, productID, and quirks are all in" 60 " where vendorID, productID, and quirks are all in"
63 " 0x-prefixed hex"); 61 " 0x-prefixed hex");
64static char *rdesc_quirks_param[MAX_USBHID_BOOT_QUIRKS] = { [ 0 ... (MAX_USBHID_BOOT_QUIRKS - 1) ] = NULL };
65module_param_array_named(rdesc_quirks, rdesc_quirks_param, charp, NULL, 0444);
66MODULE_PARM_DESC(rdesc_quirks, "Add/modify report descriptor quirks by specifying "
67 " rdesc_quirks=vendorID:productID:rdesc_quirks"
68 " where vendorID, productID, and rdesc_quirks are all in"
69 " 0x-prefixed hex");
70/* 62/*
71 * Input submission and I/O error handler. 63 * Input submission and I/O error handler.
72 */ 64 */
@@ -197,31 +189,32 @@ static void hid_irq_in(struct urb *urb)
197 int status; 189 int status;
198 190
199 switch (urb->status) { 191 switch (urb->status) {
200 case 0: /* success */ 192 case 0: /* success */
201 usbhid->retry_delay = 0; 193 usbhid->retry_delay = 0;
202 hid_input_report(urb->context, HID_INPUT_REPORT, 194 hid_input_report(urb->context, HID_INPUT_REPORT,
203 urb->transfer_buffer, 195 urb->transfer_buffer,
204 urb->actual_length, 1); 196 urb->actual_length, 1);
205 break; 197 break;
206 case -EPIPE: /* stall */ 198 case -EPIPE: /* stall */
207 clear_bit(HID_IN_RUNNING, &usbhid->iofl); 199 clear_bit(HID_IN_RUNNING, &usbhid->iofl);
208 set_bit(HID_CLEAR_HALT, &usbhid->iofl); 200 set_bit(HID_CLEAR_HALT, &usbhid->iofl);
209 schedule_work(&usbhid->reset_work); 201 schedule_work(&usbhid->reset_work);
210 return; 202 return;
211 case -ECONNRESET: /* unlink */ 203 case -ECONNRESET: /* unlink */
212 case -ENOENT: 204 case -ENOENT:
213 case -ESHUTDOWN: /* unplug */ 205 case -ESHUTDOWN: /* unplug */
214 clear_bit(HID_IN_RUNNING, &usbhid->iofl); 206 clear_bit(HID_IN_RUNNING, &usbhid->iofl);
215 return; 207 return;
216 case -EILSEQ: /* protocol error or unplug */ 208 case -EILSEQ: /* protocol error or unplug */
217 case -EPROTO: /* protocol error or unplug */ 209 case -EPROTO: /* protocol error or unplug */
218 case -ETIME: /* protocol error or unplug */ 210 case -ETIME: /* protocol error or unplug */
219 case -ETIMEDOUT: /* Should never happen, but... */ 211 case -ETIMEDOUT: /* Should never happen, but... */
220 clear_bit(HID_IN_RUNNING, &usbhid->iofl); 212 clear_bit(HID_IN_RUNNING, &usbhid->iofl);
221 hid_io_error(hid); 213 hid_io_error(hid);
222 return; 214 return;
223 default: /* error */ 215 default: /* error */
224 warn("input irq status %d received", urb->status); 216 dev_warn(&urb->dev->dev, "input irq status %d "
217 "received\n", urb->status);
225 } 218 }
226 219
227 status = usb_submit_urb(urb, GFP_ATOMIC); 220 status = usb_submit_urb(urb, GFP_ATOMIC);
@@ -240,13 +233,16 @@ static void hid_irq_in(struct urb *urb)
240static int hid_submit_out(struct hid_device *hid) 233static int hid_submit_out(struct hid_device *hid)
241{ 234{
242 struct hid_report *report; 235 struct hid_report *report;
236 char *raw_report;
243 struct usbhid_device *usbhid = hid->driver_data; 237 struct usbhid_device *usbhid = hid->driver_data;
244 238
245 report = usbhid->out[usbhid->outtail]; 239 report = usbhid->out[usbhid->outtail].report;
240 raw_report = usbhid->out[usbhid->outtail].raw_report;
246 241
247 hid_output_report(report, usbhid->outbuf);
248 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); 242 usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
249 usbhid->urbout->dev = hid_to_usb_dev(hid); 243 usbhid->urbout->dev = hid_to_usb_dev(hid);
244 memcpy(usbhid->outbuf, raw_report, usbhid->urbout->transfer_buffer_length);
245 kfree(raw_report);
250 246
251 dbg_hid("submitting out urb\n"); 247 dbg_hid("submitting out urb\n");
252 248
@@ -262,17 +258,20 @@ static int hid_submit_ctrl(struct hid_device *hid)
262{ 258{
263 struct hid_report *report; 259 struct hid_report *report;
264 unsigned char dir; 260 unsigned char dir;
261 char *raw_report;
265 int len; 262 int len;
266 struct usbhid_device *usbhid = hid->driver_data; 263 struct usbhid_device *usbhid = hid->driver_data;
267 264
268 report = usbhid->ctrl[usbhid->ctrltail].report; 265 report = usbhid->ctrl[usbhid->ctrltail].report;
266 raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report;
269 dir = usbhid->ctrl[usbhid->ctrltail].dir; 267 dir = usbhid->ctrl[usbhid->ctrltail].dir;
270 268
271 len = ((report->size - 1) >> 3) + 1 + (report->id > 0); 269 len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
272 if (dir == USB_DIR_OUT) { 270 if (dir == USB_DIR_OUT) {
273 hid_output_report(report, usbhid->ctrlbuf);
274 usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); 271 usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0);
275 usbhid->urbctrl->transfer_buffer_length = len; 272 usbhid->urbctrl->transfer_buffer_length = len;
273 memcpy(usbhid->ctrlbuf, raw_report, len);
274 kfree(raw_report);
276 } else { 275 } else {
277 int maxpacket, padlen; 276 int maxpacket, padlen;
278 277
@@ -319,17 +318,18 @@ static void hid_irq_out(struct urb *urb)
319 int unplug = 0; 318 int unplug = 0;
320 319
321 switch (urb->status) { 320 switch (urb->status) {
322 case 0: /* success */ 321 case 0: /* success */
323 break; 322 break;
324 case -ESHUTDOWN: /* unplug */ 323 case -ESHUTDOWN: /* unplug */
325 unplug = 1; 324 unplug = 1;
326 case -EILSEQ: /* protocol error or unplug */ 325 case -EILSEQ: /* protocol error or unplug */
327 case -EPROTO: /* protocol error or unplug */ 326 case -EPROTO: /* protocol error or unplug */
328 case -ECONNRESET: /* unlink */ 327 case -ECONNRESET: /* unlink */
329 case -ENOENT: 328 case -ENOENT:
330 break; 329 break;
331 default: /* error */ 330 default: /* error */
332 warn("output irq status %d received", urb->status); 331 dev_warn(&urb->dev->dev, "output irq status %d "
332 "received\n", urb->status);
333 } 333 }
334 334
335 spin_lock_irqsave(&usbhid->outlock, flags); 335 spin_lock_irqsave(&usbhid->outlock, flags);
@@ -367,21 +367,23 @@ static void hid_ctrl(struct urb *urb)
367 spin_lock_irqsave(&usbhid->ctrllock, flags); 367 spin_lock_irqsave(&usbhid->ctrllock, flags);
368 368
369 switch (urb->status) { 369 switch (urb->status) {
370 case 0: /* success */ 370 case 0: /* success */
371 if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) 371 if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN)
372 hid_input_report(urb->context, usbhid->ctrl[usbhid->ctrltail].report->type, 372 hid_input_report(urb->context,
373 urb->transfer_buffer, urb->actual_length, 0); 373 usbhid->ctrl[usbhid->ctrltail].report->type,
374 break; 374 urb->transfer_buffer, urb->actual_length, 0);
375 case -ESHUTDOWN: /* unplug */ 375 break;
376 unplug = 1; 376 case -ESHUTDOWN: /* unplug */
377 case -EILSEQ: /* protocol error or unplug */ 377 unplug = 1;
378 case -EPROTO: /* protocol error or unplug */ 378 case -EILSEQ: /* protocol error or unplug */
379 case -ECONNRESET: /* unlink */ 379 case -EPROTO: /* protocol error or unplug */
380 case -ENOENT: 380 case -ECONNRESET: /* unlink */
381 case -EPIPE: /* report not available */ 381 case -ENOENT:
382 break; 382 case -EPIPE: /* report not available */
383 default: /* error */ 383 break;
384 warn("ctrl urb status %d received", urb->status); 384 default: /* error */
385 dev_warn(&urb->dev->dev, "ctrl urb status %d "
386 "received\n", urb->status);
385 } 387 }
386 388
387 if (unplug) 389 if (unplug)
@@ -408,6 +410,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
408 int head; 410 int head;
409 unsigned long flags; 411 unsigned long flags;
410 struct usbhid_device *usbhid = hid->driver_data; 412 struct usbhid_device *usbhid = hid->driver_data;
413 int len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
411 414
412 if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN) 415 if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN)
413 return; 416 return;
@@ -418,11 +421,18 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
418 421
419 if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) { 422 if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) {
420 spin_unlock_irqrestore(&usbhid->outlock, flags); 423 spin_unlock_irqrestore(&usbhid->outlock, flags);
421 warn("output queue full"); 424 dev_warn(&hid->dev, "output queue full\n");
422 return; 425 return;
423 } 426 }
424 427
425 usbhid->out[usbhid->outhead] = report; 428 usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC);
429 if (!usbhid->out[usbhid->outhead].raw_report) {
430 spin_unlock_irqrestore(&usbhid->outlock, flags);
431 warn("output queueing failed");
432 return;
433 }
434 hid_output_report(report, usbhid->out[usbhid->outhead].raw_report);
435 usbhid->out[usbhid->outhead].report = report;
426 usbhid->outhead = head; 436 usbhid->outhead = head;
427 437
428 if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) 438 if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl))
@@ -437,10 +447,19 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
437 447
438 if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) { 448 if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) {
439 spin_unlock_irqrestore(&usbhid->ctrllock, flags); 449 spin_unlock_irqrestore(&usbhid->ctrllock, flags);
440 warn("control queue full"); 450 dev_warn(&hid->dev, "control queue full\n");
441 return; 451 return;
442 } 452 }
443 453
454 if (dir == USB_DIR_OUT) {
455 usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC);
456 if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) {
457 spin_unlock_irqrestore(&usbhid->ctrllock, flags);
458 warn("control queueing failed");
459 return;
460 }
461 hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report);
462 }
444 usbhid->ctrl[usbhid->ctrlhead].report = report; 463 usbhid->ctrl[usbhid->ctrlhead].report = report;
445 usbhid->ctrl[usbhid->ctrlhead].dir = dir; 464 usbhid->ctrl[usbhid->ctrlhead].dir = dir;
446 usbhid->ctrlhead = head; 465 usbhid->ctrlhead = head;
@@ -451,6 +470,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
451 470
452 spin_unlock_irqrestore(&usbhid->ctrllock, flags); 471 spin_unlock_irqrestore(&usbhid->ctrllock, flags);
453} 472}
473EXPORT_SYMBOL_GPL(usbhid_submit_report);
454 474
455static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 475static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
456{ 476{
@@ -465,7 +485,7 @@ static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, un
465 return -1; 485 return -1;
466 486
467 if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) { 487 if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) {
468 warn("event field not found"); 488 dev_warn(&dev->dev, "event field not found\n");
469 return -1; 489 return -1;
470 } 490 }
471 491
@@ -568,7 +588,7 @@ void usbhid_init_reports(struct hid_device *hid)
568 } 588 }
569 589
570 if (err) 590 if (err)
571 warn("timeout initializing reports"); 591 dev_warn(&hid->dev, "timeout initializing reports\n");
572} 592}
573 593
574/* 594/*
@@ -598,7 +618,7 @@ static int hid_find_field_early(struct hid_device *hid, unsigned int page,
598 return -1; 618 return -1;
599} 619}
600 620
601static void usbhid_set_leds(struct hid_device *hid) 621void usbhid_set_leds(struct hid_device *hid)
602{ 622{
603 struct hid_field *field; 623 struct hid_field *field;
604 int offset; 624 int offset;
@@ -608,6 +628,7 @@ static void usbhid_set_leds(struct hid_device *hid)
608 usbhid_submit_report(hid, field->report, USB_DIR_OUT); 628 usbhid_submit_report(hid, field->report, USB_DIR_OUT);
609 } 629 }
610} 630}
631EXPORT_SYMBOL_GPL(usbhid_set_leds);
611 632
612/* 633/*
613 * Traverse the supplied list of reports and find the longest 634 * Traverse the supplied list of reports and find the longest
@@ -675,43 +696,16 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
675 usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma); 696 usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
676} 697}
677 698
678/* 699static int usbhid_parse(struct hid_device *hid)
679 * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
680 * to "operational". Without this, the ps3 controller will not report any
681 * events.
682 */
683static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum)
684{
685 int result;
686 char *buf = kmalloc(18, GFP_KERNEL);
687
688 if (!buf)
689 return;
690
691 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
692 HID_REQ_GET_REPORT,
693 USB_DIR_IN | USB_TYPE_CLASS |
694 USB_RECIP_INTERFACE,
695 (3 << 8) | 0xf2, ifnum, buf, 17,
696 USB_CTRL_GET_TIMEOUT);
697
698 if (result < 0)
699 err_hid("%s failed: %d\n", __func__, result);
700
701 kfree(buf);
702}
703
704static struct hid_device *usb_hid_configure(struct usb_interface *intf)
705{ 700{
701 struct usb_interface *intf = to_usb_interface(hid->dev.parent);
706 struct usb_host_interface *interface = intf->cur_altsetting; 702 struct usb_host_interface *interface = intf->cur_altsetting;
707 struct usb_device *dev = interface_to_usbdev (intf); 703 struct usb_device *dev = interface_to_usbdev (intf);
708 struct hid_descriptor *hdesc; 704 struct hid_descriptor *hdesc;
709 struct hid_device *hid;
710 u32 quirks = 0; 705 u32 quirks = 0;
711 unsigned int insize = 0, rsize = 0; 706 unsigned int rsize = 0;
712 char *rdesc; 707 char *rdesc;
713 int n, len; 708 int ret, n;
714 struct usbhid_device *usbhid;
715 709
716 quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor), 710 quirks = usbhid_lookup_quirk(le16_to_cpu(dev->descriptor.idVendor),
717 le16_to_cpu(dev->descriptor.idProduct)); 711 le16_to_cpu(dev->descriptor.idProduct));
@@ -724,63 +718,75 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
724 quirks |= HID_QUIRK_NOGET; 718 quirks |= HID_QUIRK_NOGET;
725 } 719 }
726 720
727 if (quirks & HID_QUIRK_IGNORE)
728 return NULL;
729
730 if ((quirks & HID_QUIRK_IGNORE_MOUSE) &&
731 (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE))
732 return NULL;
733
734
735 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && 721 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&
736 (!interface->desc.bNumEndpoints || 722 (!interface->desc.bNumEndpoints ||
737 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { 723 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {
738 dbg_hid("class descriptor not present\n"); 724 dbg_hid("class descriptor not present\n");
739 return NULL; 725 return -ENODEV;
740 } 726 }
741 727
728 hid->version = le16_to_cpu(hdesc->bcdHID);
729 hid->country = hdesc->bCountryCode;
730
742 for (n = 0; n < hdesc->bNumDescriptors; n++) 731 for (n = 0; n < hdesc->bNumDescriptors; n++)
743 if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT) 732 if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)
744 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); 733 rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength);
745 734
746 if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) { 735 if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {
747 dbg_hid("weird size of report descriptor (%u)\n", rsize); 736 dbg_hid("weird size of report descriptor (%u)\n", rsize);
748 return NULL; 737 return -EINVAL;
749 } 738 }
750 739
751 if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) { 740 if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) {
752 dbg_hid("couldn't allocate rdesc memory\n"); 741 dbg_hid("couldn't allocate rdesc memory\n");
753 return NULL; 742 return -ENOMEM;
754 } 743 }
755 744
756 hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0); 745 hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);
757 746
758 if ((n = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber, HID_DT_REPORT, rdesc, rsize)) < 0) { 747 ret = hid_get_class_descriptor(dev, interface->desc.bInterfaceNumber,
748 HID_DT_REPORT, rdesc, rsize);
749 if (ret < 0) {
759 dbg_hid("reading report descriptor failed\n"); 750 dbg_hid("reading report descriptor failed\n");
760 kfree(rdesc); 751 kfree(rdesc);
761 return NULL; 752 goto err;
762 } 753 }
763 754
764 usbhid_fixup_report_descriptor(le16_to_cpu(dev->descriptor.idVendor),
765 le16_to_cpu(dev->descriptor.idProduct), rdesc,
766 rsize, rdesc_quirks_param);
767
768 dbg_hid("report descriptor (size %u, read %d) = ", rsize, n); 755 dbg_hid("report descriptor (size %u, read %d) = ", rsize, n);
769 for (n = 0; n < rsize; n++) 756 for (n = 0; n < rsize; n++)
770 dbg_hid_line(" %02x", (unsigned char) rdesc[n]); 757 dbg_hid_line(" %02x", (unsigned char) rdesc[n]);
771 dbg_hid_line("\n"); 758 dbg_hid_line("\n");
772 759
773 if (!(hid = hid_parse_report(rdesc, n))) { 760 ret = hid_parse_report(hid, rdesc, rsize);
761 kfree(rdesc);
762 if (ret) {
774 dbg_hid("parsing report descriptor failed\n"); 763 dbg_hid("parsing report descriptor failed\n");
775 kfree(rdesc); 764 goto err;
776 return NULL;
777 } 765 }
778 766
779 kfree(rdesc);
780 hid->quirks = quirks; 767 hid->quirks = quirks;
781 768
782 if (!(usbhid = kzalloc(sizeof(struct usbhid_device), GFP_KERNEL))) 769 return 0;
783 goto fail_no_usbhid; 770err:
771 return ret;
772}
773
774static int usbhid_start(struct hid_device *hid)
775{
776 struct usb_interface *intf = to_usb_interface(hid->dev.parent);
777 struct usb_host_interface *interface = intf->cur_altsetting;
778 struct usb_device *dev = interface_to_usbdev(intf);
779 struct usbhid_device *usbhid;
780 unsigned int n, insize = 0;
781 int ret;
782
783 WARN_ON(hid->driver_data);
784
785 usbhid = kzalloc(sizeof(struct usbhid_device), GFP_KERNEL);
786 if (usbhid == NULL) {
787 ret = -ENOMEM;
788 goto err;
789 }
784 790
785 hid->driver_data = usbhid; 791 hid->driver_data = usbhid;
786 usbhid->hid = hid; 792 usbhid->hid = hid;
@@ -799,28 +805,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
799 insize = HID_MAX_BUFFER_SIZE; 805 insize = HID_MAX_BUFFER_SIZE;
800 806
801 if (hid_alloc_buffers(dev, hid)) { 807 if (hid_alloc_buffers(dev, hid)) {
802 hid_free_buffers(dev, hid); 808 ret = -ENOMEM;
803 goto fail; 809 goto fail;
804 } 810 }
805 811
806 hid->name[0] = 0;
807
808 if (dev->manufacturer)
809 strlcpy(hid->name, dev->manufacturer, sizeof(hid->name));
810
811 if (dev->product) {
812 if (dev->manufacturer)
813 strlcat(hid->name, " ", sizeof(hid->name));
814 strlcat(hid->name, dev->product, sizeof(hid->name));
815 }
816
817 if (!strlen(hid->name))
818 snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x",
819 le16_to_cpu(dev->descriptor.idVendor),
820 le16_to_cpu(dev->descriptor.idProduct));
821
822 for (n = 0; n < interface->desc.bNumEndpoints; n++) { 812 for (n = 0; n < interface->desc.bNumEndpoints; n++) {
823
824 struct usb_endpoint_descriptor *endpoint; 813 struct usb_endpoint_descriptor *endpoint;
825 int pipe; 814 int pipe;
826 int interval; 815 int interval;
@@ -832,7 +821,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
832 interval = endpoint->bInterval; 821 interval = endpoint->bInterval;
833 822
834 /* Some vendors give fullspeed interval on highspeed devides */ 823 /* Some vendors give fullspeed interval on highspeed devides */
835 if (quirks & HID_QUIRK_FULLSPEED_INTERVAL && 824 if (hid->quirks & HID_QUIRK_FULLSPEED_INTERVAL &&
836 dev->speed == USB_SPEED_HIGH) { 825 dev->speed == USB_SPEED_HIGH) {
837 interval = fls(endpoint->bInterval*8); 826 interval = fls(endpoint->bInterval*8);
838 printk(KERN_INFO "%s: Fixing fullspeed to highspeed interval: %d -> %d\n", 827 printk(KERN_INFO "%s: Fixing fullspeed to highspeed interval: %d -> %d\n",
@@ -843,6 +832,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
843 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) 832 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0)
844 interval = hid_mousepoll_interval; 833 interval = hid_mousepoll_interval;
845 834
835 ret = -ENOMEM;
846 if (usb_endpoint_dir_in(endpoint)) { 836 if (usb_endpoint_dir_in(endpoint)) {
847 if (usbhid->urbin) 837 if (usbhid->urbin)
848 continue; 838 continue;
@@ -868,6 +858,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
868 858
869 if (!usbhid->urbin) { 859 if (!usbhid->urbin) {
870 err_hid("couldn't find an input interrupt endpoint"); 860 err_hid("couldn't find an input interrupt endpoint");
861 ret = -ENODEV;
871 goto fail; 862 goto fail;
872 } 863 }
873 864
@@ -879,44 +870,25 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
879 spin_lock_init(&usbhid->outlock); 870 spin_lock_init(&usbhid->outlock);
880 spin_lock_init(&usbhid->ctrllock); 871 spin_lock_init(&usbhid->ctrllock);
881 872
882 hid->version = le16_to_cpu(hdesc->bcdHID);
883 hid->country = hdesc->bCountryCode;
884 hid->dev = &intf->dev;
885 usbhid->intf = intf; 873 usbhid->intf = intf;
886 usbhid->ifnum = interface->desc.bInterfaceNumber; 874 usbhid->ifnum = interface->desc.bInterfaceNumber;
887 875
888 hid->bus = BUS_USB;
889 hid->vendor = le16_to_cpu(dev->descriptor.idVendor);
890 hid->product = le16_to_cpu(dev->descriptor.idProduct);
891
892 usb_make_path(dev, hid->phys, sizeof(hid->phys));
893 strlcat(hid->phys, "/input", sizeof(hid->phys));
894 len = strlen(hid->phys);
895 if (len < sizeof(hid->phys) - 1)
896 snprintf(hid->phys + len, sizeof(hid->phys) - len,
897 "%d", intf->altsetting[0].desc.bInterfaceNumber);
898
899 if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0)
900 hid->uniq[0] = 0;
901
902 usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); 876 usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);
903 if (!usbhid->urbctrl) 877 if (!usbhid->urbctrl) {
878 ret = -ENOMEM;
904 goto fail; 879 goto fail;
880 }
905 881
906 usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr, 882 usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr,
907 usbhid->ctrlbuf, 1, hid_ctrl, hid); 883 usbhid->ctrlbuf, 1, hid_ctrl, hid);
908 usbhid->urbctrl->setup_dma = usbhid->cr_dma; 884 usbhid->urbctrl->setup_dma = usbhid->cr_dma;
909 usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma; 885 usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma;
910 usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); 886 usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
911 hid->hidinput_input_event = usb_hidinput_input_event; 887
912 hid->hid_open = usbhid_open; 888 usbhid_init_reports(hid);
913 hid->hid_close = usbhid_close; 889 hid_dump_device(hid);
914#ifdef CONFIG_USB_HIDDEV 890
915 hid->hiddev_hid_event = hiddev_hid_event; 891 return 0;
916 hid->hiddev_report_event = hiddev_report_event;
917#endif
918 hid->hid_output_raw_report = usbhid_output_raw_report;
919 return hid;
920 892
921fail: 893fail:
922 usb_free_urb(usbhid->urbin); 894 usb_free_urb(usbhid->urbin);
@@ -924,24 +896,18 @@ fail:
924 usb_free_urb(usbhid->urbctrl); 896 usb_free_urb(usbhid->urbctrl);
925 hid_free_buffers(dev, hid); 897 hid_free_buffers(dev, hid);
926 kfree(usbhid); 898 kfree(usbhid);
927fail_no_usbhid: 899err:
928 hid_free_device(hid); 900 return ret;
929
930 return NULL;
931} 901}
932 902
933static void hid_disconnect(struct usb_interface *intf) 903static void usbhid_stop(struct hid_device *hid)
934{ 904{
935 struct hid_device *hid = usb_get_intfdata (intf); 905 struct usbhid_device *usbhid = hid->driver_data;
936 struct usbhid_device *usbhid;
937 906
938 if (!hid) 907 if (WARN_ON(!usbhid))
939 return; 908 return;
940 909
941 usbhid = hid->driver_data;
942
943 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ 910 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
944 usb_set_intfdata(intf, NULL);
945 set_bit(HID_DISCONNECTED, &usbhid->iofl); 911 set_bit(HID_DISCONNECTED, &usbhid->iofl);
946 spin_unlock_irq(&usbhid->inlock); 912 spin_unlock_irq(&usbhid->inlock);
947 usb_kill_urb(usbhid->urbin); 913 usb_kill_urb(usbhid->urbin);
@@ -958,86 +924,100 @@ static void hid_disconnect(struct usb_interface *intf)
958 if (hid->claimed & HID_CLAIMED_HIDRAW) 924 if (hid->claimed & HID_CLAIMED_HIDRAW)
959 hidraw_disconnect(hid); 925 hidraw_disconnect(hid);
960 926
927 hid->claimed = 0;
928
961 usb_free_urb(usbhid->urbin); 929 usb_free_urb(usbhid->urbin);
962 usb_free_urb(usbhid->urbctrl); 930 usb_free_urb(usbhid->urbctrl);
963 usb_free_urb(usbhid->urbout); 931 usb_free_urb(usbhid->urbout);
964 932
965 hid_free_buffers(hid_to_usb_dev(hid), hid); 933 hid_free_buffers(hid_to_usb_dev(hid), hid);
966 kfree(usbhid); 934 kfree(usbhid);
967 hid_free_device(hid); 935 hid->driver_data = NULL;
968} 936}
969 937
938static struct hid_ll_driver usb_hid_driver = {
939 .parse = usbhid_parse,
940 .start = usbhid_start,
941 .stop = usbhid_stop,
942 .open = usbhid_open,
943 .close = usbhid_close,
944 .hidinput_input_event = usb_hidinput_input_event,
945};
946
970static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) 947static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
971{ 948{
949 struct usb_device *dev = interface_to_usbdev(intf);
972 struct hid_device *hid; 950 struct hid_device *hid;
973 char path[64]; 951 size_t len;
974 int i; 952 int ret;
975 char *c;
976 953
977 dbg_hid("HID probe called for ifnum %d\n", 954 dbg_hid("HID probe called for ifnum %d\n",
978 intf->altsetting->desc.bInterfaceNumber); 955 intf->altsetting->desc.bInterfaceNumber);
979 956
980 if (!(hid = usb_hid_configure(intf))) 957 hid = hid_allocate_device();
981 return -ENODEV; 958 if (IS_ERR(hid))
982 959 return PTR_ERR(hid);
983 usbhid_init_reports(hid);
984 hid_dump_device(hid);
985 if (hid->quirks & HID_QUIRK_RESET_LEDS)
986 usbhid_set_leds(hid);
987
988 if (!hidinput_connect(hid))
989 hid->claimed |= HID_CLAIMED_INPUT;
990 if (!hiddev_connect(hid))
991 hid->claimed |= HID_CLAIMED_HIDDEV;
992 if (!hidraw_connect(hid))
993 hid->claimed |= HID_CLAIMED_HIDRAW;
994 960
995 usb_set_intfdata(intf, hid); 961 usb_set_intfdata(intf, hid);
962 hid->ll_driver = &usb_hid_driver;
963 hid->hid_output_raw_report = usbhid_output_raw_report;
964 hid->ff_init = hid_pidff_init;
965#ifdef CONFIG_USB_HIDDEV
966 hid->hiddev_connect = hiddev_connect;
967 hid->hiddev_hid_event = hiddev_hid_event;
968 hid->hiddev_report_event = hiddev_report_event;
969#endif
970 hid->dev.parent = &intf->dev;
971 hid->bus = BUS_USB;
972 hid->vendor = le16_to_cpu(dev->descriptor.idVendor);
973 hid->product = le16_to_cpu(dev->descriptor.idProduct);
974 hid->name[0] = 0;
996 975
997 if (!hid->claimed) { 976 if (dev->manufacturer)
998 printk ("HID device claimed by neither input, hiddev nor hidraw\n"); 977 strlcpy(hid->name, dev->manufacturer, sizeof(hid->name));
999 hid_disconnect(intf); 978
1000 return -ENODEV; 979 if (dev->product) {
980 if (dev->manufacturer)
981 strlcat(hid->name, " ", sizeof(hid->name));
982 strlcat(hid->name, dev->product, sizeof(hid->name));
1001 } 983 }
1002 984
1003 if ((hid->claimed & HID_CLAIMED_INPUT)) 985 if (!strlen(hid->name))
1004 hid_ff_init(hid); 986 snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x",
987 le16_to_cpu(dev->descriptor.idVendor),
988 le16_to_cpu(dev->descriptor.idProduct));
1005 989
1006 if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER) 990 usb_make_path(dev, hid->phys, sizeof(hid->phys));
1007 hid_fixup_sony_ps3_controller(interface_to_usbdev(intf), 991 strlcat(hid->phys, "/input", sizeof(hid->phys));
1008 intf->cur_altsetting->desc.bInterfaceNumber); 992 len = strlen(hid->phys);
993 if (len < sizeof(hid->phys) - 1)
994 snprintf(hid->phys + len, sizeof(hid->phys) - len,
995 "%d", intf->altsetting[0].desc.bInterfaceNumber);
1009 996
1010 printk(KERN_INFO); 997 if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0)
998 hid->uniq[0] = 0;
1011 999
1012 if (hid->claimed & HID_CLAIMED_INPUT) 1000 ret = hid_add_device(hid);
1013 printk("input"); 1001 if (ret) {
1014 if ((hid->claimed & HID_CLAIMED_INPUT) && ((hid->claimed & HID_CLAIMED_HIDDEV) || 1002 if (ret != -ENODEV)
1015 hid->claimed & HID_CLAIMED_HIDRAW)) 1003 dev_err(&intf->dev, "can't add hid device: %d\n", ret);
1016 printk(","); 1004 goto err;
1017 if (hid->claimed & HID_CLAIMED_HIDDEV)
1018 printk("hiddev%d", hid->minor);
1019 if ((hid->claimed & HID_CLAIMED_INPUT) && (hid->claimed & HID_CLAIMED_HIDDEV) &&
1020 (hid->claimed & HID_CLAIMED_HIDRAW))
1021 printk(",");
1022 if (hid->claimed & HID_CLAIMED_HIDRAW)
1023 printk("hidraw%d", ((struct hidraw*)hid->hidraw)->minor);
1024
1025 c = "Device";
1026 for (i = 0; i < hid->maxcollection; i++) {
1027 if (hid->collection[i].type == HID_COLLECTION_APPLICATION &&
1028 (hid->collection[i].usage & HID_USAGE_PAGE) == HID_UP_GENDESK &&
1029 (hid->collection[i].usage & 0xffff) < ARRAY_SIZE(hid_types)) {
1030 c = hid_types[hid->collection[i].usage & 0xffff];
1031 break;
1032 }
1033 } 1005 }
1034 1006
1035 usb_make_path(interface_to_usbdev(intf), path, 63); 1007 return 0;
1008err:
1009 hid_destroy_device(hid);
1010 return ret;
1011}
1036 1012
1037 printk(": USB HID v%x.%02x %s [%s] on %s\n", 1013static void hid_disconnect(struct usb_interface *intf)
1038 hid->version >> 8, hid->version & 0xff, c, hid->name, path); 1014{
1015 struct hid_device *hid = usb_get_intfdata(intf);
1039 1016
1040 return 0; 1017 if (WARN_ON(!hid))
1018 return;
1019
1020 hid_destroy_device(hid);
1041} 1021}
1042 1022
1043static int hid_suspend(struct usb_interface *intf, pm_message_t message) 1023static int hid_suspend(struct usb_interface *intf, pm_message_t message)
@@ -1107,9 +1087,22 @@ static struct usb_driver hid_driver = {
1107 .supports_autosuspend = 1, 1087 .supports_autosuspend = 1,
1108}; 1088};
1109 1089
1090static const struct hid_device_id hid_usb_table[] = {
1091 { HID_USB_DEVICE(HID_ANY_ID, HID_ANY_ID) },
1092 { }
1093};
1094
1095static struct hid_driver hid_usb_driver = {
1096 .name = "generic-usb",
1097 .id_table = hid_usb_table,
1098};
1099
1110static int __init hid_init(void) 1100static int __init hid_init(void)
1111{ 1101{
1112 int retval; 1102 int retval;
1103 retval = hid_register_driver(&hid_usb_driver);
1104 if (retval)
1105 goto hid_register_fail;
1113 retval = usbhid_quirks_init(quirks_param); 1106 retval = usbhid_quirks_init(quirks_param);
1114 if (retval) 1107 if (retval)
1115 goto usbhid_quirks_init_fail; 1108 goto usbhid_quirks_init_fail;
@@ -1119,7 +1112,8 @@ static int __init hid_init(void)
1119 retval = usb_register(&hid_driver); 1112 retval = usb_register(&hid_driver);
1120 if (retval) 1113 if (retval)
1121 goto usb_register_fail; 1114 goto usb_register_fail;
1122 info(DRIVER_VERSION ":" DRIVER_DESC); 1115 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
1116 DRIVER_DESC "\n");
1123 1117
1124 return 0; 1118 return 0;
1125usb_register_fail: 1119usb_register_fail:
@@ -1127,6 +1121,8 @@ usb_register_fail:
1127hiddev_init_fail: 1121hiddev_init_fail:
1128 usbhid_quirks_exit(); 1122 usbhid_quirks_exit();
1129usbhid_quirks_init_fail: 1123usbhid_quirks_init_fail:
1124 hid_unregister_driver(&hid_usb_driver);
1125hid_register_fail:
1130 return retval; 1126 return retval;
1131} 1127}
1132 1128
@@ -1135,6 +1131,7 @@ static void __exit hid_exit(void)
1135 usb_deregister(&hid_driver); 1131 usb_deregister(&hid_driver);
1136 hiddev_exit(); 1132 hiddev_exit();
1137 usbhid_quirks_exit(); 1133 usbhid_quirks_exit();
1134 hid_unregister_driver(&hid_usb_driver);
1138} 1135}
1139 1136
1140module_init(hid_init); 1137module_init(hid_init);
diff --git a/drivers/hid/usbhid/hid-ff.c b/drivers/hid/usbhid/hid-ff.c
deleted file mode 100644
index 1d0dac52f166..000000000000
--- a/drivers/hid/usbhid/hid-ff.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * Force feedback support for hid devices.
3 * Not all hid devices use the same protocol. For example, some use PID,
4 * other use their own proprietary procotol.
5 *
6 * Copyright (c) 2002-2004 Johann Deneux
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Should you need to contact me, the author, you can do so by
25 * e-mail - mail your message to <johann.deneux@it.uu.se>
26 */
27
28#include <linux/input.h>
29
30#undef DEBUG
31#include <linux/usb.h>
32
33#include <linux/hid.h>
34#include "usbhid.h"
35
36/*
37 * This table contains pointers to initializers. To add support for new
38 * devices, you need to add the USB vendor and product ids here.
39 */
40struct hid_ff_initializer {
41 u16 idVendor;
42 u16 idProduct;
43 int (*init)(struct hid_device*);
44};
45
46/*
47 * We try pidff when no other driver is found because PID is the
48 * standards compliant way of implementing force feedback in HID.
49 * pidff_init() will quickly abort if the device doesn't appear to
50 * be a PID device
51 */
52static struct hid_ff_initializer inits[] = {
53#ifdef CONFIG_LOGITECH_FF
54 { 0x46d, 0xc211, hid_lgff_init }, /* Logitech Cordless rumble pad */
55 { 0x46d, 0xc219, hid_lgff_init }, /* Logitech Cordless rumble pad 2 */
56 { 0x46d, 0xc283, hid_lgff_init }, /* Logitech Wingman Force 3d */
57 { 0x46d, 0xc286, hid_lgff_init }, /* Logitech Force 3D Pro Joystick */
58 { 0x46d, 0xc294, hid_lgff_init }, /* Logitech Formula Force EX */
59 { 0x46d, 0xc295, hid_lgff_init }, /* Logitech MOMO force wheel */
60 { 0x46d, 0xca03, hid_lgff_init }, /* Logitech MOMO force wheel */
61#endif
62#ifdef CONFIG_LOGIRUMBLEPAD2_FF
63 { 0x46d, 0xc218, hid_lg2ff_init }, /* Logitech Rumblepad 2 */
64#endif
65#ifdef CONFIG_PANTHERLORD_FF
66 { 0x810, 0x0001, hid_plff_init }, /* "Twin USB Joystick" */
67 { 0xe8f, 0x0003, hid_plff_init }, /* "GreenAsia Inc. USB Joystick " */
68#endif
69#ifdef CONFIG_THRUSTMASTER_FF
70 { 0x44f, 0xb300, hid_tmff_init },
71 { 0x44f, 0xb304, hid_tmff_init },
72 { 0x44f, 0xb651, hid_tmff_init }, /* FGT Rumble Force Wheel */
73 { 0x44f, 0xb654, hid_tmff_init }, /* FGT Force Feedback Wheel */
74#endif
75#ifdef CONFIG_ZEROPLUS_FF
76 { 0xc12, 0x0005, hid_zpff_init },
77 { 0xc12, 0x0030, hid_zpff_init },
78#endif
79 { 0, 0, hid_pidff_init} /* Matches anything */
80};
81
82int hid_ff_init(struct hid_device* hid)
83{
84 struct hid_ff_initializer *init;
85 int vendor = le16_to_cpu(hid_to_usb_dev(hid)->descriptor.idVendor);
86 int product = le16_to_cpu(hid_to_usb_dev(hid)->descriptor.idProduct);
87
88 for (init = inits; init->idVendor; init++)
89 if (init->idVendor == vendor && init->idProduct == product)
90 break;
91
92 return init->init(hid);
93}
94EXPORT_SYMBOL_GPL(hid_ff_init);
95
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index 011326178c06..484e3eec2f88 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -397,7 +397,6 @@ static void pidff_set_condition_report(struct pidff_device *pidff,
397 effect->u.condition[i].left_saturation); 397 effect->u.condition[i].left_saturation);
398 pidff_set(&pidff->set_condition[PID_DEAD_BAND], 398 pidff_set(&pidff->set_condition[PID_DEAD_BAND],
399 effect->u.condition[i].deadband); 399 effect->u.condition[i].deadband);
400 usbhid_wait_io(pidff->hid);
401 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION], 400 usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION],
402 USB_DIR_OUT); 401 USB_DIR_OUT);
403 } 402 }
@@ -512,7 +511,6 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
512 pidff->effect_operation[PID_LOOP_COUNT].value[0] = n; 511 pidff->effect_operation[PID_LOOP_COUNT].value[0] = n;
513 } 512 }
514 513
515 usbhid_wait_io(pidff->hid);
516 usbhid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION], 514 usbhid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION],
517 USB_DIR_OUT); 515 USB_DIR_OUT);
518} 516}
@@ -548,6 +546,9 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id)
548 int pid_id = pidff->pid_id[effect_id]; 546 int pid_id = pidff->pid_id[effect_id];
549 547
550 debug("starting to erase %d/%d", effect_id, pidff->pid_id[effect_id]); 548 debug("starting to erase %d/%d", effect_id, pidff->pid_id[effect_id]);
549 /* Wait for the queue to clear. We do not want a full fifo to
550 prevent the effect removal. */
551 usbhid_wait_io(pidff->hid);
551 pidff_playback_pid(pidff, pid_id, 0); 552 pidff_playback_pid(pidff, pid_id, 0);
552 pidff_erase_pid(pidff, pid_id); 553 pidff_erase_pid(pidff, pid_id);
553 554
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index b15f88249639..47ebe045f9b5 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -17,412 +17,7 @@
17 17
18#include <linux/hid.h> 18#include <linux/hid.h>
19 19
20#define USB_VENDOR_ID_A4TECH 0x09da 20#include "../hid-ids.h"
21#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
22#define USB_DEVICE_ID_A4TECH_X5_005D 0x000a
23
24#define USB_VENDOR_ID_AASHIMA 0x06d6
25#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025
26#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026
27
28#define USB_VENDOR_ID_ACECAD 0x0460
29#define USB_DEVICE_ID_ACECAD_FLAIR 0x0004
30#define USB_DEVICE_ID_ACECAD_302 0x0008
31
32#define USB_VENDOR_ID_ADS_TECH 0x06e1
33#define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155
34
35#define USB_VENDOR_ID_AFATECH 0x15a4
36#define USB_DEVICE_ID_AFATECH_AF9016 0x9016
37
38#define USB_VENDOR_ID_AIPTEK 0x08ca
39#define USB_DEVICE_ID_AIPTEK_01 0x0001
40#define USB_DEVICE_ID_AIPTEK_10 0x0010
41#define USB_DEVICE_ID_AIPTEK_20 0x0020
42#define USB_DEVICE_ID_AIPTEK_21 0x0021
43#define USB_DEVICE_ID_AIPTEK_22 0x0022
44#define USB_DEVICE_ID_AIPTEK_23 0x0023
45#define USB_DEVICE_ID_AIPTEK_24 0x0024
46
47#define USB_VENDOR_ID_AIRCABLE 0x16CA
48#define USB_DEVICE_ID_AIRCABLE1 0x1502
49
50#define USB_VENDOR_ID_ALCOR 0x058f
51#define USB_DEVICE_ID_ALCOR_USBRS232 0x9720
52
53#define USB_VENDOR_ID_ALPS 0x0433
54#define USB_DEVICE_ID_IBM_GAMEPAD 0x1101
55
56#define USB_VENDOR_ID_APPLE 0x05ac
57#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
58#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
59#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
60#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
61#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
62#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
63#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
64#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
65#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
66#define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a
67#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
68#define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c
69#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220
70#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221
71#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222
72#define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223
73#define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224
74#define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225
75#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229
76#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a
77#define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b
78#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c
79#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d
80#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e
81#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
82#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
83#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
84#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
85#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
86#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
87
88#define USB_VENDOR_ID_ASUS 0x0b05
89#define USB_DEVICE_ID_ASUS_LCM 0x1726
90
91#define USB_VENDOR_ID_ATEN 0x0557
92#define USB_DEVICE_ID_ATEN_UC100KM 0x2004
93#define USB_DEVICE_ID_ATEN_CS124U 0x2202
94#define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204
95#define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205
96#define USB_DEVICE_ID_ATEN_4PORTKVMC 0x2208
97
98#define USB_VENDOR_ID_BELKIN 0x050d
99#define USB_DEVICE_ID_FLIP_KVM 0x3201
100
101#define USB_VENDOR_ID_BERKSHIRE 0x0c98
102#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
103
104#define USB_VENDOR_ID_CHERRY 0x046a
105#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
106
107#define USB_VENDOR_ID_CHIC 0x05fe
108#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014
109
110#define USB_VENDOR_ID_CIDC 0x1677
111
112#define USB_VENDOR_ID_CMEDIA 0x0d8c
113#define USB_DEVICE_ID_CM109 0x000e
114
115#define USB_VENDOR_ID_CODEMERCS 0x07c0
116#define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500
117#define USB_DEVICE_ID_CODEMERCS_IOW_LAST 0x15ff
118
119#define USB_VENDOR_ID_CYGNAL 0x10c4
120#define USB_DEVICE_ID_CYGNAL_RADIO_SI470X 0x818a
121
122#define USB_VENDOR_ID_CYPRESS 0x04b4
123#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
124#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
125#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417
126#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
127#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
128
129#define USB_VENDOR_ID_DELL 0x413c
130#define USB_DEVICE_ID_DELL_W7658 0x2005
131
132#define USB_VENDOR_ID_DELORME 0x1163
133#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100
134#define USB_DEVICE_ID_DELORME_EM_LT20 0x0200
135
136#define USB_VENDOR_ID_DMI 0x0c0b
137#define USB_DEVICE_ID_DMI_ENC 0x5fab
138
139#define USB_VENDOR_ID_ELO 0x04E7
140#define USB_DEVICE_ID_ELO_TS2700 0x0020
141
142#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
143#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
144
145#define USB_VENDOR_ID_EZKEY 0x0518
146#define USB_DEVICE_ID_BTC_8193 0x0002
147
148#define USB_VENDOR_ID_GAMERON 0x0810
149#define USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR 0x0001
150
151#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc
152
153#define USB_VENDOR_ID_GLAB 0x06c2
154#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
155#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
156#define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040
157#define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044
158#define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045
159#define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051
160#define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053
161#define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058
162
163#define USB_VENDOR_ID_GOTOP 0x08f2
164#define USB_DEVICE_ID_SUPER_Q2 0x007f
165#define USB_DEVICE_ID_GOGOPEN 0x00ce
166#define USB_DEVICE_ID_PENPOWER 0x00f4
167
168#define USB_VENDOR_ID_GRETAGMACBETH 0x0971
169#define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005
170
171#define USB_VENDOR_ID_GRIFFIN 0x077d
172#define USB_DEVICE_ID_POWERMATE 0x0410
173#define USB_DEVICE_ID_SOUNDKNOB 0x04AA
174
175#define USB_VENDOR_ID_GTCO 0x078c
176#define USB_DEVICE_ID_GTCO_90 0x0090
177#define USB_DEVICE_ID_GTCO_100 0x0100
178#define USB_DEVICE_ID_GTCO_101 0x0101
179#define USB_DEVICE_ID_GTCO_103 0x0103
180#define USB_DEVICE_ID_GTCO_104 0x0104
181#define USB_DEVICE_ID_GTCO_105 0x0105
182#define USB_DEVICE_ID_GTCO_106 0x0106
183#define USB_DEVICE_ID_GTCO_107 0x0107
184#define USB_DEVICE_ID_GTCO_108 0x0108
185#define USB_DEVICE_ID_GTCO_200 0x0200
186#define USB_DEVICE_ID_GTCO_201 0x0201
187#define USB_DEVICE_ID_GTCO_202 0x0202
188#define USB_DEVICE_ID_GTCO_203 0x0203
189#define USB_DEVICE_ID_GTCO_204 0x0204
190#define USB_DEVICE_ID_GTCO_205 0x0205
191#define USB_DEVICE_ID_GTCO_206 0x0206
192#define USB_DEVICE_ID_GTCO_207 0x0207
193#define USB_DEVICE_ID_GTCO_300 0x0300
194#define USB_DEVICE_ID_GTCO_301 0x0301
195#define USB_DEVICE_ID_GTCO_302 0x0302
196#define USB_DEVICE_ID_GTCO_303 0x0303
197#define USB_DEVICE_ID_GTCO_304 0x0304
198#define USB_DEVICE_ID_GTCO_305 0x0305
199#define USB_DEVICE_ID_GTCO_306 0x0306
200#define USB_DEVICE_ID_GTCO_307 0x0307
201#define USB_DEVICE_ID_GTCO_308 0x0308
202#define USB_DEVICE_ID_GTCO_309 0x0309
203#define USB_DEVICE_ID_GTCO_400 0x0400
204#define USB_DEVICE_ID_GTCO_401 0x0401
205#define USB_DEVICE_ID_GTCO_402 0x0402
206#define USB_DEVICE_ID_GTCO_403 0x0403
207#define USB_DEVICE_ID_GTCO_404 0x0404
208#define USB_DEVICE_ID_GTCO_405 0x0405
209#define USB_DEVICE_ID_GTCO_500 0x0500
210#define USB_DEVICE_ID_GTCO_501 0x0501
211#define USB_DEVICE_ID_GTCO_502 0x0502
212#define USB_DEVICE_ID_GTCO_503 0x0503
213#define USB_DEVICE_ID_GTCO_504 0x0504
214#define USB_DEVICE_ID_GTCO_1000 0x1000
215#define USB_DEVICE_ID_GTCO_1001 0x1001
216#define USB_DEVICE_ID_GTCO_1002 0x1002
217#define USB_DEVICE_ID_GTCO_1003 0x1003
218#define USB_DEVICE_ID_GTCO_1004 0x1004
219#define USB_DEVICE_ID_GTCO_1005 0x1005
220#define USB_DEVICE_ID_GTCO_1006 0x1006
221#define USB_DEVICE_ID_GTCO_1007 0x1007
222#define USB_VENDOR_ID_HAPP 0x078b
223#define USB_DEVICE_ID_UGCI_DRIVING 0x0010
224#define USB_DEVICE_ID_UGCI_FLYING 0x0020
225#define USB_DEVICE_ID_UGCI_FIGHTING 0x0030
226
227#define USB_VENDOR_ID_IMATION 0x0718
228#define USB_DEVICE_ID_DISC_STAKKA 0xd000
229
230#define USB_VENDOR_ID_KBGEAR 0x084e
231#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
232
233#define USB_VENDOR_ID_LD 0x0f11
234#define USB_DEVICE_ID_LD_CASSY 0x1000
235#define USB_DEVICE_ID_LD_POCKETCASSY 0x1010
236#define USB_DEVICE_ID_LD_MOBILECASSY 0x1020
237#define USB_DEVICE_ID_LD_JWM 0x1080
238#define USB_DEVICE_ID_LD_DMMP 0x1081
239#define USB_DEVICE_ID_LD_UMIP 0x1090
240#define USB_DEVICE_ID_LD_XRAY1 0x1100
241#define USB_DEVICE_ID_LD_XRAY2 0x1101
242#define USB_DEVICE_ID_LD_VIDEOCOM 0x1200
243#define USB_DEVICE_ID_LD_COM3LAB 0x2000
244#define USB_DEVICE_ID_LD_TELEPORT 0x2010
245#define USB_DEVICE_ID_LD_NETWORKANALYSER 0x2020
246#define USB_DEVICE_ID_LD_POWERCONTROL 0x2030
247#define USB_DEVICE_ID_LD_MACHINETEST 0x2040
248
249#define USB_VENDOR_ID_LOGITECH 0x046d
250#define USB_DEVICE_ID_LOGITECH_LX3 0xc044
251#define USB_DEVICE_ID_LOGITECH_V150 0xc047
252#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
253#define USB_DEVICE_ID_LOGITECH_HARMONY 0xc110
254#define USB_DEVICE_ID_LOGITECH_HARMONY_2 0xc111
255#define USB_DEVICE_ID_LOGITECH_HARMONY_3 0xc112
256#define USB_DEVICE_ID_LOGITECH_HARMONY_4 0xc113
257#define USB_DEVICE_ID_LOGITECH_HARMONY_5 0xc114
258#define USB_DEVICE_ID_LOGITECH_HARMONY_6 0xc115
259#define USB_DEVICE_ID_LOGITECH_HARMONY_7 0xc116
260#define USB_DEVICE_ID_LOGITECH_HARMONY_8 0xc117
261#define USB_DEVICE_ID_LOGITECH_HARMONY_9 0xc118
262#define USB_DEVICE_ID_LOGITECH_HARMONY_10 0xc119
263#define USB_DEVICE_ID_LOGITECH_HARMONY_11 0xc11a
264#define USB_DEVICE_ID_LOGITECH_HARMONY_12 0xc11b
265#define USB_DEVICE_ID_LOGITECH_HARMONY_13 0xc11c
266#define USB_DEVICE_ID_LOGITECH_HARMONY_14 0xc11d
267#define USB_DEVICE_ID_LOGITECH_HARMONY_15 0xc11e
268#define USB_DEVICE_ID_LOGITECH_HARMONY_16 0xc11f
269#define USB_DEVICE_ID_LOGITECH_HARMONY_17 0xc120
270#define USB_DEVICE_ID_LOGITECH_HARMONY_18 0xc121
271#define USB_DEVICE_ID_LOGITECH_HARMONY_19 0xc122
272#define USB_DEVICE_ID_LOGITECH_HARMONY_20 0xc123
273#define USB_DEVICE_ID_LOGITECH_HARMONY_21 0xc124
274#define USB_DEVICE_ID_LOGITECH_HARMONY_22 0xc125
275#define USB_DEVICE_ID_LOGITECH_HARMONY_23 0xc126
276#define USB_DEVICE_ID_LOGITECH_HARMONY_24 0xc127
277#define USB_DEVICE_ID_LOGITECH_HARMONY_25 0xc128
278#define USB_DEVICE_ID_LOGITECH_HARMONY_26 0xc129
279#define USB_DEVICE_ID_LOGITECH_HARMONY_27 0xc12a
280#define USB_DEVICE_ID_LOGITECH_HARMONY_28 0xc12b
281#define USB_DEVICE_ID_LOGITECH_HARMONY_29 0xc12c
282#define USB_DEVICE_ID_LOGITECH_HARMONY_30 0xc12d
283#define USB_DEVICE_ID_LOGITECH_HARMONY_31 0xc12e
284#define USB_DEVICE_ID_LOGITECH_HARMONY_32 0xc12f
285#define USB_DEVICE_ID_LOGITECH_HARMONY_33 0xc130
286#define USB_DEVICE_ID_LOGITECH_HARMONY_34 0xc131
287#define USB_DEVICE_ID_LOGITECH_HARMONY_35 0xc132
288#define USB_DEVICE_ID_LOGITECH_HARMONY_36 0xc133
289#define USB_DEVICE_ID_LOGITECH_HARMONY_37 0xc134
290#define USB_DEVICE_ID_LOGITECH_HARMONY_38 0xc135
291#define USB_DEVICE_ID_LOGITECH_HARMONY_39 0xc136
292#define USB_DEVICE_ID_LOGITECH_HARMONY_40 0xc137
293#define USB_DEVICE_ID_LOGITECH_HARMONY_41 0xc138
294#define USB_DEVICE_ID_LOGITECH_HARMONY_42 0xc139
295#define USB_DEVICE_ID_LOGITECH_HARMONY_43 0xc13a
296#define USB_DEVICE_ID_LOGITECH_HARMONY_44 0xc13b
297#define USB_DEVICE_ID_LOGITECH_HARMONY_45 0xc13c
298#define USB_DEVICE_ID_LOGITECH_HARMONY_46 0xc13d
299#define USB_DEVICE_ID_LOGITECH_HARMONY_47 0xc13e
300#define USB_DEVICE_ID_LOGITECH_HARMONY_48 0xc13f
301#define USB_DEVICE_ID_LOGITECH_HARMONY_49 0xc140
302#define USB_DEVICE_ID_LOGITECH_HARMONY_50 0xc141
303#define USB_DEVICE_ID_LOGITECH_HARMONY_51 0xc142
304#define USB_DEVICE_ID_LOGITECH_HARMONY_52 0xc143
305#define USB_DEVICE_ID_LOGITECH_HARMONY_53 0xc144
306#define USB_DEVICE_ID_LOGITECH_HARMONY_54 0xc145
307#define USB_DEVICE_ID_LOGITECH_HARMONY_55 0xc146
308#define USB_DEVICE_ID_LOGITECH_HARMONY_56 0xc147
309#define USB_DEVICE_ID_LOGITECH_HARMONY_57 0xc148
310#define USB_DEVICE_ID_LOGITECH_HARMONY_58 0xc149
311#define USB_DEVICE_ID_LOGITECH_HARMONY_59 0xc14a
312#define USB_DEVICE_ID_LOGITECH_HARMONY_60 0xc14b
313#define USB_DEVICE_ID_LOGITECH_HARMONY_61 0xc14c
314#define USB_DEVICE_ID_LOGITECH_HARMONY_62 0xc14d
315#define USB_DEVICE_ID_LOGITECH_HARMONY_63 0xc14e
316#define USB_DEVICE_ID_LOGITECH_HARMONY_64 0xc14f
317#define USB_DEVICE_ID_LOGITECH_EXTREME_3D 0xc215
318#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
319#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a
320#define USB_DEVICE_ID_LOGITECH_KBD 0xc311
321#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
322#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
323#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
324#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513
325#define USB_DEVICE_ID_DINOVO_DESKTOP 0xc704
326#define USB_DEVICE_ID_DINOVO_EDGE 0xc714
327#define USB_DEVICE_ID_DINOVO_MINI 0xc71f
328
329#define USB_VENDOR_ID_MCC 0x09db
330#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076
331#define USB_DEVICE_ID_MCC_PMD1208LS 0x007a
332
333#define USB_VENDOR_ID_MGE 0x0463
334#define USB_DEVICE_ID_MGE_UPS 0xffff
335#define USB_DEVICE_ID_MGE_UPS1 0x0001
336
337#define USB_VENDOR_ID_MICROCHIP 0x04d8
338#define USB_DEVICE_ID_PICKIT1 0x0032
339#define USB_DEVICE_ID_PICKIT2 0x0033
340
341#define USB_VENDOR_ID_MICROSOFT 0x045e
342#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
343#define USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0 0x009d
344#define USB_DEVICE_ID_DESKTOP_RECV_1028 0x00f9
345#define USB_DEVICE_ID_MS_NE4K 0x00db
346#define USB_DEVICE_ID_MS_LK6K 0x00f9
347
348#define USB_VENDOR_ID_MONTEREY 0x0566
349#define USB_DEVICE_ID_GENIUS_KB29E 0x3004
350
351#define USB_VENDOR_ID_NCR 0x0404
352#define USB_DEVICE_ID_NCR_FIRST 0x0300
353#define USB_DEVICE_ID_NCR_LAST 0x03ff
354
355#define USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR 0x0400
356#define USB_DEVICE_ID_N_S_HARMONY 0xc359
357
358#define USB_VENDOR_ID_NATSU 0x08b7
359#define USB_DEVICE_ID_NATSU_GAMEPAD 0x0001
360
361#define USB_VENDOR_ID_NEC 0x073e
362#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
363
364#define USB_VENDOR_ID_ONTRAK 0x0a07
365#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
366
367#define USB_VENDOR_ID_PANJIT 0x134c
368
369#define USB_VENDOR_ID_PANTHERLORD 0x0810
370#define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001
371
372#define USB_VENDOR_ID_PETALYNX 0x18b1
373#define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
374
375#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43
376#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003
377
378#define USB_VENDOR_ID_SAITEK 0x06a3
379#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
380
381#define USB_VENDOR_ID_SAMSUNG 0x0419
382#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
383
384#define USB_VENDOR_ID_SONY 0x054c
385#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
386
387#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2
388#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038
389
390#define USB_VENDOR_ID_SUN 0x0430
391#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
392
393#define USB_VENDOR_ID_SUNPLUS 0x04fc
394#define USB_DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8
395
396#define USB_VENDOR_ID_TOPMAX 0x0663
397#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
398
399#define USB_VENDOR_ID_TURBOX 0x062a
400#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
401
402#define USB_VENDOR_ID_VERNIER 0x08f7
403#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
404#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
405#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
406#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
407#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
408
409#define USB_VENDOR_ID_WACOM 0x056a
410
411#define USB_VENDOR_ID_WISEGROUP 0x0925
412#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101
413#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
414#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201
415#define USB_DEVICE_ID_QUAD_USB_JOYPAD 0x8800
416#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866
417
418#define USB_VENDOR_ID_WISEGROUP_LTD 0x6677
419#define USB_DEVICE_ID_SMARTJOY_DUAL_PLUS 0x8802
420
421#define USB_VENDOR_ID_YEALINK 0x6993
422#define USB_DEVICE_ID_YEALINK_P1K_P4K_B2K 0xb001
423
424#define USB_VENDOR_ID_KYE 0x0458
425#define USB_DEVICE_ID_KYE_GPEN_560 0x5003
426 21
427/* 22/*
428 * Alphabetically sorted blacklist by quirk type. 23 * Alphabetically sorted blacklist by quirk type.
@@ -433,18 +28,10 @@ static const struct hid_blacklist {
433 __u16 idProduct; 28 __u16 idProduct;
434 __u32 quirks; 29 __u32 quirks;
435} hid_blacklist[] = { 30} hid_blacklist[] = {
436
437 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 },
438 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D, HID_QUIRK_2WHEEL_MOUSE_HACK_B8 },
439 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 },
440
441 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS },
442
443 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, 31 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD },
444 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, 32 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD },
445 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, 33 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
446 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, 34 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
447 { USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR, HID_QUIRK_MULTI_INPUT },
448 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 35 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
449 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 36 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
450 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 37 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
@@ -453,169 +40,11 @@ static const struct hid_blacklist {
453 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, 40 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD },
454 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, 41 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
455 42
456 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP, HID_QUIRK_DUPLICATE_USAGES },
457 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE, HID_QUIRK_DUPLICATE_USAGES },
458 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI, HID_QUIRK_DUPLICATE_USAGES },
459
460 { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL }, 43 { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL },
461 44
462 { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV },
463 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4, HID_QUIRK_HIDDEV | HID_QUIRK_IGNORE_HIDINPUT },
464 { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_HIDDEV | HID_QUIRK_IGNORE_HIDINPUT },
465 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV, HID_QUIRK_HIDINPUT },
466
467 { USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193, HID_QUIRK_HWHEEL_WHEEL_INVERT },
468
469 { USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X, HID_QUIRK_IGNORE },
470 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01, HID_QUIRK_IGNORE },
471 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10, HID_QUIRK_IGNORE },
472 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20, HID_QUIRK_IGNORE },
473 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21, HID_QUIRK_IGNORE },
474 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE },
475 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE },
476 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE },
477 { USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1, HID_QUIRK_IGNORE },
478 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE },
479 { USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM, HID_QUIRK_IGNORE},
480 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE },
481 { USB_VENDOR_ID_CIDC, 0x0103, HID_QUIRK_IGNORE },
482 { USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X, HID_QUIRK_IGNORE },
483 { USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109, HID_QUIRK_IGNORE },
484 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE },
485 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE },
486 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE },
487 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE },
488 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE },
489 { USB_VENDOR_ID_GENERAL_TOUCH, 0x0001, HID_QUIRK_IGNORE },
490 { USB_VENDOR_ID_GENERAL_TOUCH, 0x0002, HID_QUIRK_IGNORE },
491 { USB_VENDOR_ID_GENERAL_TOUCH, 0x0003, HID_QUIRK_IGNORE },
492 { USB_VENDOR_ID_GENERAL_TOUCH, 0x0004, HID_QUIRK_IGNORE },
493 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE },
494 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE },
495 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT, HID_QUIRK_IGNORE },
496 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT, HID_QUIRK_IGNORE },
497 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT, HID_QUIRK_IGNORE },
498 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT, HID_QUIRK_IGNORE },
499 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT, HID_QUIRK_IGNORE },
500 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL, HID_QUIRK_IGNORE },
501 { USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2, HID_QUIRK_IGNORE },
502 { USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN, HID_QUIRK_IGNORE },
503 { USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER, HID_QUIRK_IGNORE },
504 { USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY, HID_QUIRK_IGNORE },
505 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE },
506 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE },
507 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90, HID_QUIRK_IGNORE },
508 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100, HID_QUIRK_IGNORE },
509 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101, HID_QUIRK_IGNORE },
510 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103, HID_QUIRK_IGNORE },
511 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104, HID_QUIRK_IGNORE },
512 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105, HID_QUIRK_IGNORE },
513 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106, HID_QUIRK_IGNORE },
514 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107, HID_QUIRK_IGNORE },
515 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108, HID_QUIRK_IGNORE },
516 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200, HID_QUIRK_IGNORE },
517 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201, HID_QUIRK_IGNORE },
518 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202, HID_QUIRK_IGNORE },
519 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203, HID_QUIRK_IGNORE },
520 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204, HID_QUIRK_IGNORE },
521 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205, HID_QUIRK_IGNORE },
522 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206, HID_QUIRK_IGNORE },
523 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207, HID_QUIRK_IGNORE },
524 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300, HID_QUIRK_IGNORE },
525 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301, HID_QUIRK_IGNORE },
526 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302, HID_QUIRK_IGNORE },
527 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303, HID_QUIRK_IGNORE },
528 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304, HID_QUIRK_IGNORE },
529 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305, HID_QUIRK_IGNORE },
530 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306, HID_QUIRK_IGNORE },
531 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307, HID_QUIRK_IGNORE },
532 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308, HID_QUIRK_IGNORE },
533 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309, HID_QUIRK_IGNORE },
534 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400, HID_QUIRK_IGNORE },
535 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401, HID_QUIRK_IGNORE },
536 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402, HID_QUIRK_IGNORE },
537 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403, HID_QUIRK_IGNORE },
538 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404, HID_QUIRK_IGNORE },
539 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405, HID_QUIRK_IGNORE },
540 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500, HID_QUIRK_IGNORE },
541 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501, HID_QUIRK_IGNORE },
542 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE },
543 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE },
544 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE },
545 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE },
546 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE },
547 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE },
548 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003, HID_QUIRK_IGNORE },
549 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE },
550 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE },
551 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE },
552 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007, HID_QUIRK_IGNORE },
553 { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE },
554 { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE },
555 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE },
556 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY, HID_QUIRK_IGNORE },
557 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY, HID_QUIRK_IGNORE },
558 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM, HID_QUIRK_IGNORE },
559 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP, HID_QUIRK_IGNORE },
560 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP, HID_QUIRK_IGNORE },
561 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1, HID_QUIRK_IGNORE },
562 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2, HID_QUIRK_IGNORE },
563 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM, HID_QUIRK_IGNORE },
564 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB, HID_QUIRK_IGNORE },
565 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT, HID_QUIRK_IGNORE },
566 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER, HID_QUIRK_IGNORE },
567 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL, HID_QUIRK_IGNORE },
568 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST, HID_QUIRK_IGNORE },
569 { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS, HID_QUIRK_IGNORE },
570 { USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS, HID_QUIRK_IGNORE },
571 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_IGNORE },
572 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_IGNORE },
573 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100, HID_QUIRK_IGNORE },
574 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20, HID_QUIRK_IGNORE },
575 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30, HID_QUIRK_IGNORE },
576 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100, HID_QUIRK_IGNORE },
577 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108, HID_QUIRK_IGNORE },
578 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118, HID_QUIRK_IGNORE },
579 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200, HID_QUIRK_IGNORE },
580 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE },
581 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE },
582 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE },
583 { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE },
584 { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE },
585 { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE },
586 { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE },
587 { USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD, HID_QUIRK_IGNORE },
588 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO, HID_QUIRK_IGNORE },
589 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE },
590 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE },
591 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE },
592 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC, HID_QUIRK_IGNORE },
593 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
594 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
595 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE },
596 { USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K, HID_QUIRK_IGNORE },
597
598 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE },
599 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE },
600
601 { USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1, HID_QUIRK_IGNORE },
602 { USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2, HID_QUIRK_IGNORE },
603
604 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD, HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL | HID_QUIRK_LOGITECH_EXPANDED_KEYMAP },
605 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500, HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL | HID_QUIRK_LOGITECH_EXPANDED_KEYMAP },
606 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_LX3, HID_QUIRK_INVERT_HWHEEL },
607 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_V150, HID_QUIRK_INVERT_HWHEEL },
608
609 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K, HID_QUIRK_MICROSOFT_KEYS },
610 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K, HID_QUIRK_MICROSOFT_KEYS },
611
612 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },
613
614 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 45 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
615 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, 46 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
616 47
617 { USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, HID_QUIRK_SONY_PS3_CONTROLLER | HID_QUIRK_HIDDEV },
618
619 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, 48 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET },
620 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, 49 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
621 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, 50 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
@@ -623,144 +52,13 @@ static const struct hid_blacklist {
623 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 52 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
624 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 53 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
625 { 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 },
626 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D, HID_QUIRK_NOGET },
627 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET },
628 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0, HID_QUIRK_NOGET },
629 { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_NOGET },
630 { 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 },
631 { 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 },
632 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 57 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
633 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 58 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
634 59
635 { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 60 { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
636 61 { USB_VENDOR_ID_WISEGROUP_LTD2, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
637 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
638 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
639 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
640 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD},
641 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
642 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
643 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD},
644 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
645 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
646 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD},
647 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
648 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI, HID_QUIRK_APPLE_HAS_FN },
649 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
650 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN },
651 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
652 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
653 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
654 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN },
655 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
656 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN },
657 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
658 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD | HID_QUIRK_IGNORE_MOUSE},
659 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE},
660 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE},
661 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD | HID_QUIRK_IGNORE_MOUSE },
662 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
663 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
664 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_NUMLOCK_EMULATION | HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
665
666 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS },
667 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD, HID_QUIRK_RESET_LEDS },
668 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY, HID_QUIRK_IGNORE },
669 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_2, HID_QUIRK_IGNORE },
670 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_3, HID_QUIRK_IGNORE },
671 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_4, HID_QUIRK_IGNORE },
672 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_5, HID_QUIRK_IGNORE },
673 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_6, HID_QUIRK_IGNORE },
674 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_7, HID_QUIRK_IGNORE },
675 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_8, HID_QUIRK_IGNORE },
676 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_9, HID_QUIRK_IGNORE },
677 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_10, HID_QUIRK_IGNORE },
678 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_11, HID_QUIRK_IGNORE },
679 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_12, HID_QUIRK_IGNORE },
680 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_13, HID_QUIRK_IGNORE },
681 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_14, HID_QUIRK_IGNORE },
682 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_15, HID_QUIRK_IGNORE },
683 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_16, HID_QUIRK_IGNORE },
684 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_17, HID_QUIRK_IGNORE },
685 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_18, HID_QUIRK_IGNORE },
686 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_19, HID_QUIRK_IGNORE },
687 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_20, HID_QUIRK_IGNORE },
688 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_21, HID_QUIRK_IGNORE },
689 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_22, HID_QUIRK_IGNORE },
690 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_23, HID_QUIRK_IGNORE },
691 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_24, HID_QUIRK_IGNORE },
692 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_25, HID_QUIRK_IGNORE },
693 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_26, HID_QUIRK_IGNORE },
694 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_27, HID_QUIRK_IGNORE },
695 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_28, HID_QUIRK_IGNORE },
696 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_29, HID_QUIRK_IGNORE },
697 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_30, HID_QUIRK_IGNORE },
698 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_31, HID_QUIRK_IGNORE },
699 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_32, HID_QUIRK_IGNORE },
700 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_33, HID_QUIRK_IGNORE },
701 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_34, HID_QUIRK_IGNORE },
702 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_35, HID_QUIRK_IGNORE },
703 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_36, HID_QUIRK_IGNORE },
704 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_37, HID_QUIRK_IGNORE },
705 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_38, HID_QUIRK_IGNORE },
706 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_39, HID_QUIRK_IGNORE },
707 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_40, HID_QUIRK_IGNORE },
708 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_41, HID_QUIRK_IGNORE },
709 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_42, HID_QUIRK_IGNORE },
710 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_43, HID_QUIRK_IGNORE },
711 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_44, HID_QUIRK_IGNORE },
712 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_45, HID_QUIRK_IGNORE },
713 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_46, HID_QUIRK_IGNORE },
714 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_47, HID_QUIRK_IGNORE },
715 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_48, HID_QUIRK_IGNORE },
716 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_49, HID_QUIRK_IGNORE },
717 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_50, HID_QUIRK_IGNORE },
718 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_51, HID_QUIRK_IGNORE },
719 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_52, HID_QUIRK_IGNORE },
720 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_53, HID_QUIRK_IGNORE },
721 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_54, HID_QUIRK_IGNORE },
722 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_55, HID_QUIRK_IGNORE },
723 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_56, HID_QUIRK_IGNORE },
724 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_57, HID_QUIRK_IGNORE },
725 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_58, HID_QUIRK_IGNORE },
726 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_59, HID_QUIRK_IGNORE },
727 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_60, HID_QUIRK_IGNORE },
728 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_61, HID_QUIRK_IGNORE },
729 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_62, HID_QUIRK_IGNORE },
730 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_63, HID_QUIRK_IGNORE },
731 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_64, HID_QUIRK_IGNORE },
732 { USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY, HID_QUIRK_IGNORE },
733 { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560, HID_QUIRK_IGNORE },
734
735 { 0, 0 }
736};
737
738/* Quirks for devices which require report descriptor fixup go here */
739static const struct hid_rdesc_blacklist {
740 __u16 idVendor;
741 __u16 idProduct;
742 __u32 quirks;
743} hid_rdesc_blacklist[] = {
744
745 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_RDESC_CYMOTION },
746
747 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER, HID_QUIRK_RDESC_LOGITECH },
748 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER, HID_QUIRK_RDESC_LOGITECH },
749 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2, HID_QUIRK_RDESC_LOGITECH },
750 { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_DESKTOP_RECV_1028, HID_QUIRK_RDESC_MICROSOFT_RECV_1028 },
751
752 { USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER },
753
754 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_RDESC_MACBOOK_JIS },
755
756 { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_RDESC_PETALYNX },
757
758 { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_RDESC_SAMSUNG_REMOTE },
759
760 { USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP, HID_QUIRK_RDESC_SUNPLUS_WDESKTOP },
761
762 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_RDESC_SWAPPED_MIN_MAX },
763 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2, HID_QUIRK_RDESC_SWAPPED_MIN_MAX },
764 62
765 { 0, 0 } 63 { 0, 0 }
766}; 64};
@@ -974,16 +272,6 @@ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct)
974 u32 quirks = 0; 272 u32 quirks = 0;
975 const struct hid_blacklist *bl_entry = NULL; 273 const struct hid_blacklist *bl_entry = NULL;
976 274
977 /* Ignore all Wacom devices */
978 if (idVendor == USB_VENDOR_ID_WACOM)
979 return HID_QUIRK_IGNORE;
980
981 /* ignore all Code Mercenaries IOWarrior devices */
982 if (idVendor == USB_VENDOR_ID_CODEMERCS)
983 if (idProduct >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
984 idProduct <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
985 return HID_QUIRK_IGNORE;
986
987 /* NCR devices must not be queried for reports */ 275 /* NCR devices must not be queried for reports */
988 if (idVendor == USB_VENDOR_ID_NCR && 276 if (idVendor == USB_VENDOR_ID_NCR &&
989 idProduct >= USB_DEVICE_ID_NCR_FIRST && 277 idProduct >= USB_DEVICE_ID_NCR_FIRST &&
@@ -1002,221 +290,3 @@ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct)
1002} 290}
1003 291
1004EXPORT_SYMBOL_GPL(usbhid_lookup_quirk); 292EXPORT_SYMBOL_GPL(usbhid_lookup_quirk);
1005
1006/*
1007 * Cherry Cymotion keyboard have an invalid HID report descriptor,
1008 * that needs fixing before we can parse it.
1009 */
1010static void usbhid_fixup_cymotion_descriptor(char *rdesc, int rsize)
1011{
1012 if (rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
1013 printk(KERN_INFO "Fixing up Cherry Cymotion report descriptor\n");
1014 rdesc[11] = rdesc[16] = 0xff;
1015 rdesc[12] = rdesc[17] = 0x03;
1016 }
1017}
1018
1019
1020/*
1021 * Certain Logitech keyboards send in report #3 keys which are far
1022 * above the logical maximum described in descriptor. This extends
1023 * the original value of 0x28c of logical maximum to 0x104d
1024 */
1025static void usbhid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize)
1026{
1027 if (rsize >= 90 && rdesc[83] == 0x26
1028 && rdesc[84] == 0x8c
1029 && rdesc[85] == 0x02) {
1030 printk(KERN_INFO "Fixing up Logitech keyboard report descriptor\n");
1031 rdesc[84] = rdesc[89] = 0x4d;
1032 rdesc[85] = rdesc[90] = 0x10;
1033 }
1034}
1035
1036static void usbhid_fixup_sunplus_wdesktop(unsigned char *rdesc, int rsize)
1037{
1038 if (rsize >= 107 && rdesc[104] == 0x26
1039 && rdesc[105] == 0x80
1040 && rdesc[106] == 0x03) {
1041 printk(KERN_INFO "Fixing up Sunplus Wireless Desktop report descriptor\n");
1042 rdesc[105] = rdesc[110] = 0x03;
1043 rdesc[106] = rdesc[111] = 0x21;
1044 }
1045}
1046
1047/*
1048 * Samsung IrDA remote controller (reports as Cypress USB Mouse).
1049 *
1050 * Vendor specific report #4 has a size of 48 bit,
1051 * and therefore is not accepted when inspecting the descriptors.
1052 * As a workaround we reinterpret the report as:
1053 * Variable type, count 6, size 8 bit, log. maximum 255
1054 * The burden to reconstruct the data is moved into user space.
1055 */
1056static void usbhid_fixup_samsung_irda_descriptor(unsigned char *rdesc,
1057 int rsize)
1058{
1059 if (rsize >= 182 && rdesc[175] == 0x25
1060 && rdesc[176] == 0x40
1061 && rdesc[177] == 0x75
1062 && rdesc[178] == 0x30
1063 && rdesc[179] == 0x95
1064 && rdesc[180] == 0x01
1065 && rdesc[182] == 0x40) {
1066 printk(KERN_INFO "Fixing up Samsung IrDA report descriptor\n");
1067 rdesc[176] = 0xff;
1068 rdesc[178] = 0x08;
1069 rdesc[180] = 0x06;
1070 rdesc[182] = 0x42;
1071 }
1072}
1073
1074/* Petalynx Maxter Remote has maximum for consumer page set too low */
1075static void usbhid_fixup_petalynx_descriptor(unsigned char *rdesc, int rsize)
1076{
1077 if (rsize >= 60 && rdesc[39] == 0x2a
1078 && rdesc[40] == 0xf5
1079 && rdesc[41] == 0x00
1080 && rdesc[59] == 0x26
1081 && rdesc[60] == 0xf9
1082 && rdesc[61] == 0x00) {
1083 printk(KERN_INFO "Fixing up Petalynx Maxter Remote report descriptor\n");
1084 rdesc[60] = 0xfa;
1085 rdesc[40] = 0xfa;
1086 }
1087}
1088
1089/*
1090 * Some USB barcode readers from cypress have usage min and usage max in
1091 * the wrong order
1092 */
1093static void usbhid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize)
1094{
1095 short fixed = 0;
1096 int i;
1097
1098 for (i = 0; i < rsize - 4; i++) {
1099 if (rdesc[i] == 0x29 && rdesc [i+2] == 0x19) {
1100 unsigned char tmp;
1101
1102 rdesc[i] = 0x19; rdesc[i+2] = 0x29;
1103 tmp = rdesc[i+3];
1104 rdesc[i+3] = rdesc[i+1];
1105 rdesc[i+1] = tmp;
1106 }
1107 }
1108
1109 if (fixed)
1110 printk(KERN_INFO "Fixing up Cypress report descriptor\n");
1111}
1112
1113/*
1114 * MacBook JIS keyboard has wrong logical maximum
1115 */
1116static void usbhid_fixup_macbook_descriptor(unsigned char *rdesc, int rsize)
1117{
1118 if (rsize >= 60 && rdesc[53] == 0x65
1119 && rdesc[59] == 0x65) {
1120 printk(KERN_INFO "Fixing up MacBook JIS keyboard report descriptor\n");
1121 rdesc[53] = rdesc[59] = 0xe7;
1122 }
1123}
1124
1125static void usbhid_fixup_button_consumer_descriptor(unsigned char *rdesc, int rsize)
1126{
1127 if (rsize >= 30 && rdesc[29] == 0x05
1128 && rdesc[30] == 0x09) {
1129 printk(KERN_INFO "Fixing up button/consumer in HID report descriptor\n");
1130 rdesc[30] = 0x0c;
1131 }
1132}
1133
1134/*
1135 * Microsoft Wireless Desktop Receiver (Model 1028) has several
1136 * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
1137 */
1138static void usbhid_fixup_microsoft_descriptor(unsigned char *rdesc, int rsize)
1139{
1140 if (rsize == 571 && rdesc[284] == 0x19
1141 && rdesc[286] == 0x2a
1142 && rdesc[304] == 0x19
1143 && rdesc[306] == 0x29
1144 && rdesc[352] == 0x1a
1145 && rdesc[355] == 0x2a
1146 && rdesc[557] == 0x19
1147 && rdesc[559] == 0x29) {
1148 printk(KERN_INFO "Fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n");
1149 rdesc[284] = rdesc[304] = rdesc[557] = 0x35;
1150 rdesc[352] = 0x36;
1151 rdesc[286] = rdesc[355] = 0x46;
1152 rdesc[306] = rdesc[559] = 0x45;
1153 }
1154}
1155
1156static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize)
1157{
1158 if ((quirks & HID_QUIRK_RDESC_CYMOTION))
1159 usbhid_fixup_cymotion_descriptor(rdesc, rsize);
1160
1161 if (quirks & HID_QUIRK_RDESC_LOGITECH)
1162 usbhid_fixup_logitech_descriptor(rdesc, rsize);
1163
1164 if (quirks & HID_QUIRK_RDESC_SWAPPED_MIN_MAX)
1165 usbhid_fixup_cypress_descriptor(rdesc, rsize);
1166
1167 if (quirks & HID_QUIRK_RDESC_PETALYNX)
1168 usbhid_fixup_petalynx_descriptor(rdesc, rsize);
1169
1170 if (quirks & HID_QUIRK_RDESC_MACBOOK_JIS)
1171 usbhid_fixup_macbook_descriptor(rdesc, rsize);
1172
1173 if (quirks & HID_QUIRK_RDESC_BUTTON_CONSUMER)
1174 usbhid_fixup_button_consumer_descriptor(rdesc, rsize);
1175
1176 if (quirks & HID_QUIRK_RDESC_SAMSUNG_REMOTE)
1177 usbhid_fixup_samsung_irda_descriptor(rdesc, rsize);
1178
1179 if (quirks & HID_QUIRK_RDESC_MICROSOFT_RECV_1028)
1180 usbhid_fixup_microsoft_descriptor(rdesc, rsize);
1181
1182 if (quirks & HID_QUIRK_RDESC_SUNPLUS_WDESKTOP)
1183 usbhid_fixup_sunplus_wdesktop(rdesc, rsize);
1184}
1185
1186/**
1187 * usbhid_fixup_report_descriptor: check if report descriptor needs fixup
1188 *
1189 * Description:
1190 * Walks the hid_rdesc_blacklist[] array and checks whether the device
1191 * is known to have broken report descriptor that needs to be fixed up
1192 * prior to entering the HID parser
1193 *
1194 * Returns: nothing
1195 */
1196void usbhid_fixup_report_descriptor(const u16 idVendor, const u16 idProduct,
1197 char *rdesc, unsigned rsize, char **quirks_param)
1198{
1199 int n, m;
1200 u16 paramVendor, paramProduct;
1201 u32 quirks;
1202
1203 /* static rdesc quirk entries */
1204 for (n = 0; hid_rdesc_blacklist[n].idVendor; n++)
1205 if (hid_rdesc_blacklist[n].idVendor == idVendor &&
1206 hid_rdesc_blacklist[n].idProduct == idProduct)
1207 __usbhid_fixup_report_descriptor(hid_rdesc_blacklist[n].quirks,
1208 rdesc, rsize);
1209
1210 /* runtime rdesc quirk entries handling */
1211 for (n = 0; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) {
1212 m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x",
1213 &paramVendor, &paramProduct, &quirks);
1214
1215 if (m != 3)
1216 printk(KERN_WARNING
1217 "Could not parse HID quirk module param %s\n",
1218 quirks_param[n]);
1219 else if (paramVendor == idVendor && paramProduct == idProduct)
1220 __usbhid_fixup_report_descriptor(quirks, rdesc, rsize);
1221 }
1222}
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 842e9edb888e..babd65dd46ad 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -790,21 +790,23 @@ static struct usb_class_driver hiddev_class = {
790/* 790/*
791 * This is where hid.c calls us to connect a hid device to the hiddev driver 791 * This is where hid.c calls us to connect a hid device to the hiddev driver
792 */ 792 */
793int hiddev_connect(struct hid_device *hid) 793int hiddev_connect(struct hid_device *hid, unsigned int force)
794{ 794{
795 struct hiddev *hiddev; 795 struct hiddev *hiddev;
796 struct usbhid_device *usbhid = hid->driver_data; 796 struct usbhid_device *usbhid = hid->driver_data;
797 int i;
798 int retval; 797 int retval;
799 798
800 for (i = 0; i < hid->maxcollection; i++) 799 if (!force) {
801 if (hid->collection[i].type == 800 unsigned int i;
802 HID_COLLECTION_APPLICATION && 801 for (i = 0; i < hid->maxcollection; i++)
803 !IS_INPUT_APPLICATION(hid->collection[i].usage)) 802 if (hid->collection[i].type ==
804 break; 803 HID_COLLECTION_APPLICATION &&
804 !IS_INPUT_APPLICATION(hid->collection[i].usage))
805 break;
805 806
806 if (i == hid->maxcollection && (hid->quirks & HID_QUIRK_HIDDEV) == 0) 807 if (i == hid->maxcollection)
807 return -1; 808 return -1;
809 }
808 810
809 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL))) 811 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
810 return -1; 812 return -1;
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 62d2d7c925bd..abedb13c623e 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -67,7 +67,7 @@ struct usbhid_device {
67 spinlock_t ctrllock; /* Control fifo spinlock */ 67 spinlock_t ctrllock; /* Control fifo spinlock */
68 68
69 struct urb *urbout; /* Output URB */ 69 struct urb *urbout; /* Output URB */
70 struct hid_report *out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */ 70 struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
71 unsigned char outhead, outtail; /* Output pipe fifo head & tail */ 71 unsigned char outhead, outtail; /* Output pipe fifo head & tail */
72 char *outbuf; /* Output buffer */ 72 char *outbuf; /* Output buffer */
73 dma_addr_t outbuf_dma; /* Output buffer dma */ 73 dma_addr_t outbuf_dma; /* Output buffer dma */
@@ -82,7 +82,7 @@ struct usbhid_device {
82}; 82};
83 83
84#define hid_to_usb_dev(hid_dev) \ 84#define hid_to_usb_dev(hid_dev) \
85 container_of(hid_dev->dev->parent, struct usb_device, dev) 85 container_of(hid_dev->dev.parent->parent, struct usb_device, dev)
86 86
87#endif 87#endif
88 88
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 0caaafe01843..b342926dd7fc 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -105,14 +105,16 @@ static void usb_kbd_irq(struct urb *urb)
105 if (usb_kbd_keycode[kbd->old[i]]) 105 if (usb_kbd_keycode[kbd->old[i]])
106 input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); 106 input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0);
107 else 107 else
108 info("Unknown key (scancode %#x) released.", kbd->old[i]); 108 dev_info(&urb->dev->dev,
109 "Unknown key (scancode %#x) released.\n", kbd->old[i]);
109 } 110 }
110 111
111 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { 112 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) {
112 if (usb_kbd_keycode[kbd->new[i]]) 113 if (usb_kbd_keycode[kbd->new[i]])
113 input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); 114 input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1);
114 else 115 else
115 info("Unknown key (scancode %#x) pressed.", kbd->new[i]); 116 dev_info(&urb->dev->dev,
117 "Unknown key (scancode %#x) released.\n", kbd->new[i]);
116 } 118 }
117 } 119 }
118 120
@@ -159,7 +161,8 @@ static void usb_kbd_led(struct urb *urb)
159 struct usb_kbd *kbd = urb->context; 161 struct usb_kbd *kbd = urb->context;
160 162
161 if (urb->status) 163 if (urb->status)
162 warn("led urb status %d received", urb->status); 164 dev_warn(&urb->dev->dev, "led urb status %d received\n",
165 urb->status);
163 166
164 if (*(kbd->leds) == kbd->newleds) 167 if (*(kbd->leds) == kbd->newleds)
165 return; 168 return;
@@ -352,7 +355,8 @@ static int __init usb_kbd_init(void)
352{ 355{
353 int result = usb_register(&usb_kbd_driver); 356 int result = usb_register(&usb_kbd_driver);
354 if (result == 0) 357 if (result == 0)
355 info(DRIVER_VERSION ":" DRIVER_DESC); 358 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
359 DRIVER_DESC "\n");
356 return result; 360 return result;
357} 361}
358 362
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c
index 35689ef172cc..72ab4b268096 100644
--- a/drivers/hid/usbhid/usbmouse.c
+++ b/drivers/hid/usbhid/usbmouse.c
@@ -31,6 +31,11 @@
31#include <linux/usb/input.h> 31#include <linux/usb/input.h>
32#include <linux/hid.h> 32#include <linux/hid.h>
33 33
34/* for apple IDs */
35#ifdef CONFIG_USB_HID_MODULE
36#include "../hid-ids.h"
37#endif
38
34/* 39/*
35 * Version Information 40 * Version Information
36 */ 41 */
@@ -240,7 +245,8 @@ static int __init usb_mouse_init(void)
240{ 245{
241 int retval = usb_register(&usb_mouse_driver); 246 int retval = usb_register(&usb_mouse_driver);
242 if (retval == 0) 247 if (retval == 0)
243 info(DRIVER_VERSION ":" DRIVER_DESC); 248 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
249 DRIVER_DESC "\n");
244 return retval; 250 return retval;
245} 251}
246 252
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index daa9d4220331..82ec6b1b6467 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -458,35 +458,35 @@ static int hp_sdc_rtc_proc_output (char *buf)
458 p += sprintf(p, "i8042 rtc\t: READ FAILED!\n"); 458 p += sprintf(p, "i8042 rtc\t: READ FAILED!\n");
459 } else { 459 } else {
460 p += sprintf(p, "i8042 rtc\t: %ld.%02d seconds\n", 460 p += sprintf(p, "i8042 rtc\t: %ld.%02d seconds\n",
461 tv.tv_sec, tv.tv_usec/1000); 461 tv.tv_sec, (int)tv.tv_usec/1000);
462 } 462 }
463 463
464 if (hp_sdc_rtc_read_fhs(&tv)) { 464 if (hp_sdc_rtc_read_fhs(&tv)) {
465 p += sprintf(p, "handshake\t: READ FAILED!\n"); 465 p += sprintf(p, "handshake\t: READ FAILED!\n");
466 } else { 466 } else {
467 p += sprintf(p, "handshake\t: %ld.%02d seconds\n", 467 p += sprintf(p, "handshake\t: %ld.%02d seconds\n",
468 tv.tv_sec, tv.tv_usec/1000); 468 tv.tv_sec, (int)tv.tv_usec/1000);
469 } 469 }
470 470
471 if (hp_sdc_rtc_read_mt(&tv)) { 471 if (hp_sdc_rtc_read_mt(&tv)) {
472 p += sprintf(p, "alarm\t\t: READ FAILED!\n"); 472 p += sprintf(p, "alarm\t\t: READ FAILED!\n");
473 } else { 473 } else {
474 p += sprintf(p, "alarm\t\t: %ld.%02d seconds\n", 474 p += sprintf(p, "alarm\t\t: %ld.%02d seconds\n",
475 tv.tv_sec, tv.tv_usec/1000); 475 tv.tv_sec, (int)tv.tv_usec/1000);
476 } 476 }
477 477
478 if (hp_sdc_rtc_read_dt(&tv)) { 478 if (hp_sdc_rtc_read_dt(&tv)) {
479 p += sprintf(p, "delay\t\t: READ FAILED!\n"); 479 p += sprintf(p, "delay\t\t: READ FAILED!\n");
480 } else { 480 } else {
481 p += sprintf(p, "delay\t\t: %ld.%02d seconds\n", 481 p += sprintf(p, "delay\t\t: %ld.%02d seconds\n",
482 tv.tv_sec, tv.tv_usec/1000); 482 tv.tv_sec, (int)tv.tv_usec/1000);
483 } 483 }
484 484
485 if (hp_sdc_rtc_read_ct(&tv)) { 485 if (hp_sdc_rtc_read_ct(&tv)) {
486 p += sprintf(p, "periodic\t: READ FAILED!\n"); 486 p += sprintf(p, "periodic\t: READ FAILED!\n");
487 } else { 487 } else {
488 p += sprintf(p, "periodic\t: %ld.%02d seconds\n", 488 p += sprintf(p, "periodic\t: %ld.%02d seconds\n",
489 tv.tv_sec, tv.tv_usec/1000); 489 tv.tv_sec, (int)tv.tv_usec/1000);
490 } 490 }
491 491
492 p += sprintf(p, 492 p += sprintf(p,
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index 0d395979b2d1..bfe49243f38b 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -323,7 +323,7 @@ static void hp_sdc_tasklet(unsigned long foo)
323 * it back to the application. and be less verbose. 323 * it back to the application. and be less verbose.
324 */ 324 */
325 printk(KERN_WARNING PREFIX "read timeout (%ius)!\n", 325 printk(KERN_WARNING PREFIX "read timeout (%ius)!\n",
326 tv.tv_usec - hp_sdc.rtv.tv_usec); 326 (int)(tv.tv_usec - hp_sdc.rtv.tv_usec));
327 curr->idx += hp_sdc.rqty; 327 curr->idx += hp_sdc.rqty;
328 hp_sdc.rqty = 0; 328 hp_sdc.rqty = 0;
329 tmp = curr->seq[curr->actidx]; 329 tmp = curr->seq[curr->actidx];
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index e92b1ba4b45e..c2f51cc50760 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -452,10 +452,10 @@ one_member:
452 if (finddsp->features.pcm_id == dsp->features.pcm_id) { 452 if (finddsp->features.pcm_id == dsp->features.pcm_id) {
453 if (finddsp->pcm_slot_rx >= 0 && 453 if (finddsp->pcm_slot_rx >= 0 &&
454 finddsp->pcm_slot_rx < sizeof(freeslots)) 454 finddsp->pcm_slot_rx < sizeof(freeslots))
455 freeslots[finddsp->pcm_slot_tx] = 0; 455 freeslots[finddsp->pcm_slot_rx] = 0;
456 if (finddsp->pcm_slot_tx >= 0 && 456 if (finddsp->pcm_slot_tx >= 0 &&
457 finddsp->pcm_slot_tx < sizeof(freeslots)) 457 finddsp->pcm_slot_tx < sizeof(freeslots))
458 freeslots[finddsp->pcm_slot_rx] = 0; 458 freeslots[finddsp->pcm_slot_tx] = 0;
459 } 459 }
460 } 460 }
461 i = 0; 461 i = 0;
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index e7462924b505..875fabe16e36 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -61,7 +61,7 @@ mISDN_open(struct inode *ino, struct file *filep)
61 init_waitqueue_head(&dev->wait); 61 init_waitqueue_head(&dev->wait);
62 filep->private_data = dev; 62 filep->private_data = dev;
63 __module_get(THIS_MODULE); 63 __module_get(THIS_MODULE);
64 return 0; 64 return nonseekable_open(ino, filep);
65} 65}
66 66
67static int 67static int
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 07d92c11b5d8..2281b5098e95 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -30,6 +30,20 @@ config BLK_DEV_MD
30 30
31 If unsure, say N. 31 If unsure, say N.
32 32
33config MD_AUTODETECT
34 bool "Autodetect RAID arrays during kernel boot"
35 depends on BLK_DEV_MD=y
36 default y
37 ---help---
38 If you say Y here, then the kernel will try to autodetect raid
39 arrays as part of its boot process.
40
41 If you don't use raid and say Y, this autodetection can cause
42 a several-second delay in the boot time due to various
43 synchronisation steps that are part of this step.
44
45 If unsure, say Y.
46
33config MD_LINEAR 47config MD_LINEAR
34 tristate "Linear (append) mode" 48 tristate "Linear (append) mode"
35 depends on BLK_DEV_MD 49 depends on BLK_DEV_MD
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 0dae245c6259..5eff8ad834d6 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -87,6 +87,44 @@ config MFD_TC6393XB
87 help 87 help
88 Support for Toshiba Mobile IO Controller TC6393XB 88 Support for Toshiba Mobile IO Controller TC6393XB
89 89
90config MFD_WM8400
91 tristate "Support Wolfson Microelectronics WM8400"
92 help
93 Support for the Wolfson Microelecronics WM8400 PMIC and audio
94 CODEC. This driver adds provides common support for accessing
95 the device, additional drivers must be enabled in order to use
96 the functionality of the device.
97
98config MFD_WM8350
99 tristate
100
101config MFD_WM8350_CONFIG_MODE_0
102 bool
103 depends on MFD_WM8350
104
105config MFD_WM8350_CONFIG_MODE_1
106 bool
107 depends on MFD_WM8350
108
109config MFD_WM8350_CONFIG_MODE_2
110 bool
111 depends on MFD_WM8350
112
113config MFD_WM8350_CONFIG_MODE_3
114 bool
115 depends on MFD_WM8350
116
117config MFD_WM8350_I2C
118 tristate "Support Wolfson Microelectronics WM8350 with I2C"
119 select MFD_WM8350
120 depends on I2C
121 help
122 The WM8350 is an integrated audio and power management
123 subsystem with watchdog and RTC functionality for embedded
124 systems. This option enables core support for the WM8350 with
125 I2C as the control interface. Additional options must be
126 selected to enable support for the functionality of the chip.
127
90endmenu 128endmenu
91 129
92menu "Multimedia Capabilities Port drivers" 130menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 6abebe364419..759b1fe1c891 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -12,6 +12,11 @@ obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o
12obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o 12obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o
13obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o 13obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o
14 14
15obj-$(CONFIG_MFD_WM8400) += wm8400-core.o
16wm8350-objs := wm8350-core.o wm8350-regmap.o wm8350-gpio.o
17obj-$(CONFIG_MFD_WM8350) += wm8350.o
18obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
19
15obj-$(CONFIG_MFD_CORE) += mfd-core.o 20obj-$(CONFIG_MFD_CORE) += mfd-core.o
16 21
17obj-$(CONFIG_MCP) += mcp-core.o 22obj-$(CONFIG_MCP) += mcp-core.o
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
new file mode 100644
index 000000000000..25a7a5d08bce
--- /dev/null
+++ b/drivers/mfd/wm8350-core.c
@@ -0,0 +1,1273 @@
1/*
2 * wm8350-core.c -- Device access for Wolfson WM8350
3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood, Mark Brown
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/bug.h>
19#include <linux/device.h>
20#include <linux/delay.h>
21#include <linux/interrupt.h>
22#include <linux/workqueue.h>
23
24#include <linux/mfd/wm8350/core.h>
25#include <linux/mfd/wm8350/audio.h>
26#include <linux/mfd/wm8350/comparator.h>
27#include <linux/mfd/wm8350/gpio.h>
28#include <linux/mfd/wm8350/pmic.h>
29#include <linux/mfd/wm8350/rtc.h>
30#include <linux/mfd/wm8350/supply.h>
31#include <linux/mfd/wm8350/wdt.h>
32
33#define WM8350_UNLOCK_KEY 0x0013
34#define WM8350_LOCK_KEY 0x0000
35
36#define WM8350_CLOCK_CONTROL_1 0x28
37#define WM8350_AIF_TEST 0x74
38
39/* debug */
40#define WM8350_BUS_DEBUG 0
41#if WM8350_BUS_DEBUG
42#define dump(regs, src) do { \
43 int i_; \
44 u16 *src_ = src; \
45 printk(KERN_DEBUG); \
46 for (i_ = 0; i_ < regs; i_++) \
47 printk(" 0x%4.4x", *src_++); \
48 printk("\n"); \
49} while (0);
50#else
51#define dump(bytes, src)
52#endif
53
54#define WM8350_LOCK_DEBUG 0
55#if WM8350_LOCK_DEBUG
56#define ldbg(format, arg...) printk(format, ## arg)
57#else
58#define ldbg(format, arg...)
59#endif
60
61/*
62 * WM8350 Device IO
63 */
64static DEFINE_MUTEX(io_mutex);
65static DEFINE_MUTEX(reg_lock_mutex);
66static DEFINE_MUTEX(auxadc_mutex);
67
68/* Perform a physical read from the device.
69 */
70static int wm8350_phys_read(struct wm8350 *wm8350, u8 reg, int num_regs,
71 u16 *dest)
72{
73 int i, ret;
74 int bytes = num_regs * 2;
75
76 dev_dbg(wm8350->dev, "volatile read\n");
77 ret = wm8350->read_dev(wm8350, reg, bytes, (char *)dest);
78
79 for (i = reg; i < reg + num_regs; i++) {
80 /* Cache is CPU endian */
81 dest[i - reg] = be16_to_cpu(dest[i - reg]);
82
83 /* Satisfy non-volatile bits from cache */
84 dest[i - reg] &= wm8350_reg_io_map[i].vol;
85 dest[i - reg] |= wm8350->reg_cache[i];
86
87 /* Mask out non-readable bits */
88 dest[i - reg] &= wm8350_reg_io_map[i].readable;
89 }
90
91 dump(num_regs, dest);
92
93 return ret;
94}
95
96static int wm8350_read(struct wm8350 *wm8350, u8 reg, int num_regs, u16 *dest)
97{
98 int i;
99 int end = reg + num_regs;
100 int ret = 0;
101 int bytes = num_regs * 2;
102
103 if (wm8350->read_dev == NULL)
104 return -ENODEV;
105
106 if ((reg + num_regs - 1) > WM8350_MAX_REGISTER) {
107 dev_err(wm8350->dev, "invalid reg %x\n",
108 reg + num_regs - 1);
109 return -EINVAL;
110 }
111
112 dev_dbg(wm8350->dev,
113 "%s R%d(0x%2.2x) %d regs\n", __func__, reg, reg, num_regs);
114
115#if WM8350_BUS_DEBUG
116 /* we can _safely_ read any register, but warn if read not supported */
117 for (i = reg; i < end; i++) {
118 if (!wm8350_reg_io_map[i].readable)
119 dev_warn(wm8350->dev,
120 "reg R%d is not readable\n", i);
121 }
122#endif
123
124 /* if any volatile registers are required, then read back all */
125 for (i = reg; i < end; i++)
126 if (wm8350_reg_io_map[i].vol)
127 return wm8350_phys_read(wm8350, reg, num_regs, dest);
128
129 /* no volatiles, then cache is good */
130 dev_dbg(wm8350->dev, "cache read\n");
131 memcpy(dest, &wm8350->reg_cache[reg], bytes);
132 dump(num_regs, dest);
133 return ret;
134}
135
136static inline int is_reg_locked(struct wm8350 *wm8350, u8 reg)
137{
138 if (reg == WM8350_SECURITY ||
139 wm8350->reg_cache[WM8350_SECURITY] == WM8350_UNLOCK_KEY)
140 return 0;
141
142 if ((reg == WM8350_GPIO_CONFIGURATION_I_O) ||
143 (reg >= WM8350_GPIO_FUNCTION_SELECT_1 &&
144 reg <= WM8350_GPIO_FUNCTION_SELECT_4) ||
145 (reg >= WM8350_BATTERY_CHARGER_CONTROL_1 &&
146 reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
147 return 1;
148 return 0;
149}
150
151static int wm8350_write(struct wm8350 *wm8350, u8 reg, int num_regs, u16 *src)
152{
153 int i;
154 int end = reg + num_regs;
155 int bytes = num_regs * 2;
156
157 if (wm8350->write_dev == NULL)
158 return -ENODEV;
159
160 if ((reg + num_regs - 1) > WM8350_MAX_REGISTER) {
161 dev_err(wm8350->dev, "invalid reg %x\n",
162 reg + num_regs - 1);
163 return -EINVAL;
164 }
165
166 /* it's generally not a good idea to write to RO or locked registers */
167 for (i = reg; i < end; i++) {
168 if (!wm8350_reg_io_map[i].writable) {
169 dev_err(wm8350->dev,
170 "attempted write to read only reg R%d\n", i);
171 return -EINVAL;
172 }
173
174 if (is_reg_locked(wm8350, i)) {
175 dev_err(wm8350->dev,
176 "attempted write to locked reg R%d\n", i);
177 return -EINVAL;
178 }
179
180 src[i - reg] &= wm8350_reg_io_map[i].writable;
181
182 wm8350->reg_cache[i] =
183 (wm8350->reg_cache[i] & ~wm8350_reg_io_map[i].writable)
184 | src[i - reg];
185
186 src[i - reg] = cpu_to_be16(src[i - reg]);
187 }
188
189 /* Actually write it out */
190 return wm8350->write_dev(wm8350, reg, bytes, (char *)src);
191}
192
193/*
194 * Safe read, modify, write methods
195 */
196int wm8350_clear_bits(struct wm8350 *wm8350, u16 reg, u16 mask)
197{
198 u16 data;
199 int err;
200
201 mutex_lock(&io_mutex);
202 err = wm8350_read(wm8350, reg, 1, &data);
203 if (err) {
204 dev_err(wm8350->dev, "read from reg R%d failed\n", reg);
205 goto out;
206 }
207
208 data &= ~mask;
209 err = wm8350_write(wm8350, reg, 1, &data);
210 if (err)
211 dev_err(wm8350->dev, "write to reg R%d failed\n", reg);
212out:
213 mutex_unlock(&io_mutex);
214 return err;
215}
216EXPORT_SYMBOL_GPL(wm8350_clear_bits);
217
218int wm8350_set_bits(struct wm8350 *wm8350, u16 reg, u16 mask)
219{
220 u16 data;
221 int err;
222
223 mutex_lock(&io_mutex);
224 err = wm8350_read(wm8350, reg, 1, &data);
225 if (err) {
226 dev_err(wm8350->dev, "read from reg R%d failed\n", reg);
227 goto out;
228 }
229
230 data |= mask;
231 err = wm8350_write(wm8350, reg, 1, &data);
232 if (err)
233 dev_err(wm8350->dev, "write to reg R%d failed\n", reg);
234out:
235 mutex_unlock(&io_mutex);
236 return err;
237}
238EXPORT_SYMBOL_GPL(wm8350_set_bits);
239
240u16 wm8350_reg_read(struct wm8350 *wm8350, int reg)
241{
242 u16 data;
243 int err;
244
245 mutex_lock(&io_mutex);
246 err = wm8350_read(wm8350, reg, 1, &data);
247 if (err)
248 dev_err(wm8350->dev, "read from reg R%d failed\n", reg);
249
250 mutex_unlock(&io_mutex);
251 return data;
252}
253EXPORT_SYMBOL_GPL(wm8350_reg_read);
254
255int wm8350_reg_write(struct wm8350 *wm8350, int reg, u16 val)
256{
257 int ret;
258 u16 data = val;
259
260 mutex_lock(&io_mutex);
261 ret = wm8350_write(wm8350, reg, 1, &data);
262 if (ret)
263 dev_err(wm8350->dev, "write to reg R%d failed\n", reg);
264 mutex_unlock(&io_mutex);
265 return ret;
266}
267EXPORT_SYMBOL_GPL(wm8350_reg_write);
268
269int wm8350_block_read(struct wm8350 *wm8350, int start_reg, int regs,
270 u16 *dest)
271{
272 int err = 0;
273
274 mutex_lock(&io_mutex);
275 err = wm8350_read(wm8350, start_reg, regs, dest);
276 if (err)
277 dev_err(wm8350->dev, "block read starting from R%d failed\n",
278 start_reg);
279 mutex_unlock(&io_mutex);
280 return err;
281}
282EXPORT_SYMBOL_GPL(wm8350_block_read);
283
284int wm8350_block_write(struct wm8350 *wm8350, int start_reg, int regs,
285 u16 *src)
286{
287 int ret = 0;
288
289 mutex_lock(&io_mutex);
290 ret = wm8350_write(wm8350, start_reg, regs, src);
291 if (ret)
292 dev_err(wm8350->dev, "block write starting at R%d failed\n",
293 start_reg);
294 mutex_unlock(&io_mutex);
295 return ret;
296}
297EXPORT_SYMBOL_GPL(wm8350_block_write);
298
299int wm8350_reg_lock(struct wm8350 *wm8350)
300{
301 u16 key = WM8350_LOCK_KEY;
302 int ret;
303
304 ldbg(__func__);
305 mutex_lock(&io_mutex);
306 ret = wm8350_write(wm8350, WM8350_SECURITY, 1, &key);
307 if (ret)
308 dev_err(wm8350->dev, "lock failed\n");
309 mutex_unlock(&io_mutex);
310 return ret;
311}
312EXPORT_SYMBOL_GPL(wm8350_reg_lock);
313
314int wm8350_reg_unlock(struct wm8350 *wm8350)
315{
316 u16 key = WM8350_UNLOCK_KEY;
317 int ret;
318
319 ldbg(__func__);
320 mutex_lock(&io_mutex);
321 ret = wm8350_write(wm8350, WM8350_SECURITY, 1, &key);
322 if (ret)
323 dev_err(wm8350->dev, "unlock failed\n");
324 mutex_unlock(&io_mutex);
325 return ret;
326}
327EXPORT_SYMBOL_GPL(wm8350_reg_unlock);
328
329static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
330{
331 mutex_lock(&wm8350->irq_mutex);
332
333 if (wm8350->irq[irq].handler)
334 wm8350->irq[irq].handler(wm8350, irq, wm8350->irq[irq].data);
335 else {
336 dev_err(wm8350->dev, "irq %d nobody cared. now masked.\n",
337 irq);
338 wm8350_mask_irq(wm8350, irq);
339 }
340
341 mutex_unlock(&wm8350->irq_mutex);
342}
343
344/*
345 * wm8350_irq_worker actually handles the interrupts. Since all
346 * interrupts are clear on read the IRQ line will be reasserted and
347 * the physical IRQ will be handled again if another interrupt is
348 * asserted while we run - in the normal course of events this is a
349 * rare occurrence so we save I2C/SPI reads.
350 */
351static void wm8350_irq_worker(struct work_struct *work)
352{
353 struct wm8350 *wm8350 = container_of(work, struct wm8350, irq_work);
354 u16 level_one, status1, status2, comp;
355
356 /* TODO: Use block reads to improve performance? */
357 level_one = wm8350_reg_read(wm8350, WM8350_SYSTEM_INTERRUPTS)
358 & ~wm8350_reg_read(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK);
359 status1 = wm8350_reg_read(wm8350, WM8350_INT_STATUS_1)
360 & ~wm8350_reg_read(wm8350, WM8350_INT_STATUS_1_MASK);
361 status2 = wm8350_reg_read(wm8350, WM8350_INT_STATUS_2)
362 & ~wm8350_reg_read(wm8350, WM8350_INT_STATUS_2_MASK);
363 comp = wm8350_reg_read(wm8350, WM8350_COMPARATOR_INT_STATUS)
364 & ~wm8350_reg_read(wm8350, WM8350_COMPARATOR_INT_STATUS_MASK);
365
366 /* over current */
367 if (level_one & WM8350_OC_INT) {
368 u16 oc;
369
370 oc = wm8350_reg_read(wm8350, WM8350_OVER_CURRENT_INT_STATUS);
371 oc &= ~wm8350_reg_read(wm8350,
372 WM8350_OVER_CURRENT_INT_STATUS_MASK);
373
374 if (oc & WM8350_OC_LS_EINT) /* limit switch */
375 wm8350_irq_call_handler(wm8350, WM8350_IRQ_OC_LS);
376 }
377
378 /* under voltage */
379 if (level_one & WM8350_UV_INT) {
380 u16 uv;
381
382 uv = wm8350_reg_read(wm8350, WM8350_UNDER_VOLTAGE_INT_STATUS);
383 uv &= ~wm8350_reg_read(wm8350,
384 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK);
385
386 if (uv & WM8350_UV_DC1_EINT)
387 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC1);
388 if (uv & WM8350_UV_DC2_EINT)
389 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC2);
390 if (uv & WM8350_UV_DC3_EINT)
391 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC3);
392 if (uv & WM8350_UV_DC4_EINT)
393 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC4);
394 if (uv & WM8350_UV_DC5_EINT)
395 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC5);
396 if (uv & WM8350_UV_DC6_EINT)
397 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_DC6);
398 if (uv & WM8350_UV_LDO1_EINT)
399 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO1);
400 if (uv & WM8350_UV_LDO2_EINT)
401 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO2);
402 if (uv & WM8350_UV_LDO3_EINT)
403 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO3);
404 if (uv & WM8350_UV_LDO4_EINT)
405 wm8350_irq_call_handler(wm8350, WM8350_IRQ_UV_LDO4);
406 }
407
408 /* charger, RTC */
409 if (status1) {
410 if (status1 & WM8350_CHG_BAT_HOT_EINT)
411 wm8350_irq_call_handler(wm8350,
412 WM8350_IRQ_CHG_BAT_HOT);
413 if (status1 & WM8350_CHG_BAT_COLD_EINT)
414 wm8350_irq_call_handler(wm8350,
415 WM8350_IRQ_CHG_BAT_COLD);
416 if (status1 & WM8350_CHG_BAT_FAIL_EINT)
417 wm8350_irq_call_handler(wm8350,
418 WM8350_IRQ_CHG_BAT_FAIL);
419 if (status1 & WM8350_CHG_TO_EINT)
420 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CHG_TO);
421 if (status1 & WM8350_CHG_END_EINT)
422 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CHG_END);
423 if (status1 & WM8350_CHG_START_EINT)
424 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CHG_START);
425 if (status1 & WM8350_CHG_FAST_RDY_EINT)
426 wm8350_irq_call_handler(wm8350,
427 WM8350_IRQ_CHG_FAST_RDY);
428 if (status1 & WM8350_CHG_VBATT_LT_3P9_EINT)
429 wm8350_irq_call_handler(wm8350,
430 WM8350_IRQ_CHG_VBATT_LT_3P9);
431 if (status1 & WM8350_CHG_VBATT_LT_3P1_EINT)
432 wm8350_irq_call_handler(wm8350,
433 WM8350_IRQ_CHG_VBATT_LT_3P1);
434 if (status1 & WM8350_CHG_VBATT_LT_2P85_EINT)
435 wm8350_irq_call_handler(wm8350,
436 WM8350_IRQ_CHG_VBATT_LT_2P85);
437 if (status1 & WM8350_RTC_ALM_EINT)
438 wm8350_irq_call_handler(wm8350, WM8350_IRQ_RTC_ALM);
439 if (status1 & WM8350_RTC_SEC_EINT)
440 wm8350_irq_call_handler(wm8350, WM8350_IRQ_RTC_SEC);
441 if (status1 & WM8350_RTC_PER_EINT)
442 wm8350_irq_call_handler(wm8350, WM8350_IRQ_RTC_PER);
443 }
444
445 /* current sink, system, aux adc */
446 if (status2) {
447 if (status2 & WM8350_CS1_EINT)
448 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CS1);
449 if (status2 & WM8350_CS2_EINT)
450 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CS2);
451
452 if (status2 & WM8350_SYS_HYST_COMP_FAIL_EINT)
453 wm8350_irq_call_handler(wm8350,
454 WM8350_IRQ_SYS_HYST_COMP_FAIL);
455 if (status2 & WM8350_SYS_CHIP_GT115_EINT)
456 wm8350_irq_call_handler(wm8350,
457 WM8350_IRQ_SYS_CHIP_GT115);
458 if (status2 & WM8350_SYS_CHIP_GT140_EINT)
459 wm8350_irq_call_handler(wm8350,
460 WM8350_IRQ_SYS_CHIP_GT140);
461 if (status2 & WM8350_SYS_WDOG_TO_EINT)
462 wm8350_irq_call_handler(wm8350,
463 WM8350_IRQ_SYS_WDOG_TO);
464
465 if (status2 & WM8350_AUXADC_DATARDY_EINT)
466 wm8350_irq_call_handler(wm8350,
467 WM8350_IRQ_AUXADC_DATARDY);
468 if (status2 & WM8350_AUXADC_DCOMP4_EINT)
469 wm8350_irq_call_handler(wm8350,
470 WM8350_IRQ_AUXADC_DCOMP4);
471 if (status2 & WM8350_AUXADC_DCOMP3_EINT)
472 wm8350_irq_call_handler(wm8350,
473 WM8350_IRQ_AUXADC_DCOMP3);
474 if (status2 & WM8350_AUXADC_DCOMP2_EINT)
475 wm8350_irq_call_handler(wm8350,
476 WM8350_IRQ_AUXADC_DCOMP2);
477 if (status2 & WM8350_AUXADC_DCOMP1_EINT)
478 wm8350_irq_call_handler(wm8350,
479 WM8350_IRQ_AUXADC_DCOMP1);
480
481 if (status2 & WM8350_USB_LIMIT_EINT)
482 wm8350_irq_call_handler(wm8350, WM8350_IRQ_USB_LIMIT);
483 }
484
485 /* wake, codec, ext */
486 if (comp) {
487 if (comp & WM8350_WKUP_OFF_STATE_EINT)
488 wm8350_irq_call_handler(wm8350,
489 WM8350_IRQ_WKUP_OFF_STATE);
490 if (comp & WM8350_WKUP_HIB_STATE_EINT)
491 wm8350_irq_call_handler(wm8350,
492 WM8350_IRQ_WKUP_HIB_STATE);
493 if (comp & WM8350_WKUP_CONV_FAULT_EINT)
494 wm8350_irq_call_handler(wm8350,
495 WM8350_IRQ_WKUP_CONV_FAULT);
496 if (comp & WM8350_WKUP_WDOG_RST_EINT)
497 wm8350_irq_call_handler(wm8350,
498 WM8350_IRQ_WKUP_WDOG_RST);
499 if (comp & WM8350_WKUP_GP_PWR_ON_EINT)
500 wm8350_irq_call_handler(wm8350,
501 WM8350_IRQ_WKUP_GP_PWR_ON);
502 if (comp & WM8350_WKUP_ONKEY_EINT)
503 wm8350_irq_call_handler(wm8350, WM8350_IRQ_WKUP_ONKEY);
504 if (comp & WM8350_WKUP_GP_WAKEUP_EINT)
505 wm8350_irq_call_handler(wm8350,
506 WM8350_IRQ_WKUP_GP_WAKEUP);
507
508 if (comp & WM8350_CODEC_JCK_DET_L_EINT)
509 wm8350_irq_call_handler(wm8350,
510 WM8350_IRQ_CODEC_JCK_DET_L);
511 if (comp & WM8350_CODEC_JCK_DET_R_EINT)
512 wm8350_irq_call_handler(wm8350,
513 WM8350_IRQ_CODEC_JCK_DET_R);
514 if (comp & WM8350_CODEC_MICSCD_EINT)
515 wm8350_irq_call_handler(wm8350,
516 WM8350_IRQ_CODEC_MICSCD);
517 if (comp & WM8350_CODEC_MICD_EINT)
518 wm8350_irq_call_handler(wm8350, WM8350_IRQ_CODEC_MICD);
519
520 if (comp & WM8350_EXT_USB_FB_EINT)
521 wm8350_irq_call_handler(wm8350, WM8350_IRQ_EXT_USB_FB);
522 if (comp & WM8350_EXT_WALL_FB_EINT)
523 wm8350_irq_call_handler(wm8350,
524 WM8350_IRQ_EXT_WALL_FB);
525 if (comp & WM8350_EXT_BAT_FB_EINT)
526 wm8350_irq_call_handler(wm8350, WM8350_IRQ_EXT_BAT_FB);
527 }
528
529 if (level_one & WM8350_GP_INT) {
530 int i;
531 u16 gpio;
532
533 gpio = wm8350_reg_read(wm8350, WM8350_GPIO_INT_STATUS);
534 gpio &= ~wm8350_reg_read(wm8350,
535 WM8350_GPIO_INT_STATUS_MASK);
536
537 for (i = 0; i < 12; i++) {
538 if (gpio & (1 << i))
539 wm8350_irq_call_handler(wm8350,
540 WM8350_IRQ_GPIO(i));
541 }
542 }
543
544 enable_irq(wm8350->chip_irq);
545}
546
547static irqreturn_t wm8350_irq(int irq, void *data)
548{
549 struct wm8350 *wm8350 = data;
550
551 disable_irq_nosync(irq);
552 schedule_work(&wm8350->irq_work);
553
554 return IRQ_HANDLED;
555}
556
557int wm8350_register_irq(struct wm8350 *wm8350, int irq,
558 void (*handler) (struct wm8350 *, int, void *),
559 void *data)
560{
561 if (irq < 0 || irq > WM8350_NUM_IRQ || !handler)
562 return -EINVAL;
563
564 if (wm8350->irq[irq].handler)
565 return -EBUSY;
566
567 mutex_lock(&wm8350->irq_mutex);
568 wm8350->irq[irq].handler = handler;
569 wm8350->irq[irq].data = data;
570 mutex_unlock(&wm8350->irq_mutex);
571
572 return 0;
573}
574EXPORT_SYMBOL_GPL(wm8350_register_irq);
575
576int wm8350_free_irq(struct wm8350 *wm8350, int irq)
577{
578 if (irq < 0 || irq > WM8350_NUM_IRQ)
579 return -EINVAL;
580
581 mutex_lock(&wm8350->irq_mutex);
582 wm8350->irq[irq].handler = NULL;
583 mutex_unlock(&wm8350->irq_mutex);
584 return 0;
585}
586EXPORT_SYMBOL_GPL(wm8350_free_irq);
587
588int wm8350_mask_irq(struct wm8350 *wm8350, int irq)
589{
590 switch (irq) {
591 case WM8350_IRQ_CHG_BAT_HOT:
592 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
593 WM8350_IM_CHG_BAT_HOT_EINT);
594 case WM8350_IRQ_CHG_BAT_COLD:
595 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
596 WM8350_IM_CHG_BAT_COLD_EINT);
597 case WM8350_IRQ_CHG_BAT_FAIL:
598 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
599 WM8350_IM_CHG_BAT_FAIL_EINT);
600 case WM8350_IRQ_CHG_TO:
601 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
602 WM8350_IM_CHG_TO_EINT);
603 case WM8350_IRQ_CHG_END:
604 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
605 WM8350_IM_CHG_END_EINT);
606 case WM8350_IRQ_CHG_START:
607 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
608 WM8350_IM_CHG_START_EINT);
609 case WM8350_IRQ_CHG_FAST_RDY:
610 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
611 WM8350_IM_CHG_FAST_RDY_EINT);
612 case WM8350_IRQ_RTC_PER:
613 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
614 WM8350_IM_RTC_PER_EINT);
615 case WM8350_IRQ_RTC_SEC:
616 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
617 WM8350_IM_RTC_SEC_EINT);
618 case WM8350_IRQ_RTC_ALM:
619 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
620 WM8350_IM_RTC_ALM_EINT);
621 case WM8350_IRQ_CHG_VBATT_LT_3P9:
622 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
623 WM8350_IM_CHG_VBATT_LT_3P9_EINT);
624 case WM8350_IRQ_CHG_VBATT_LT_3P1:
625 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
626 WM8350_IM_CHG_VBATT_LT_3P1_EINT);
627 case WM8350_IRQ_CHG_VBATT_LT_2P85:
628 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_1_MASK,
629 WM8350_IM_CHG_VBATT_LT_2P85_EINT);
630 case WM8350_IRQ_CS1:
631 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
632 WM8350_IM_CS1_EINT);
633 case WM8350_IRQ_CS2:
634 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
635 WM8350_IM_CS2_EINT);
636 case WM8350_IRQ_USB_LIMIT:
637 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
638 WM8350_IM_USB_LIMIT_EINT);
639 case WM8350_IRQ_AUXADC_DATARDY:
640 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
641 WM8350_IM_AUXADC_DATARDY_EINT);
642 case WM8350_IRQ_AUXADC_DCOMP4:
643 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
644 WM8350_IM_AUXADC_DCOMP4_EINT);
645 case WM8350_IRQ_AUXADC_DCOMP3:
646 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
647 WM8350_IM_AUXADC_DCOMP3_EINT);
648 case WM8350_IRQ_AUXADC_DCOMP2:
649 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
650 WM8350_IM_AUXADC_DCOMP2_EINT);
651 case WM8350_IRQ_AUXADC_DCOMP1:
652 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
653 WM8350_IM_AUXADC_DCOMP1_EINT);
654 case WM8350_IRQ_SYS_HYST_COMP_FAIL:
655 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
656 WM8350_IM_SYS_HYST_COMP_FAIL_EINT);
657 case WM8350_IRQ_SYS_CHIP_GT115:
658 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
659 WM8350_IM_SYS_CHIP_GT115_EINT);
660 case WM8350_IRQ_SYS_CHIP_GT140:
661 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
662 WM8350_IM_SYS_CHIP_GT140_EINT);
663 case WM8350_IRQ_SYS_WDOG_TO:
664 return wm8350_set_bits(wm8350, WM8350_INT_STATUS_2_MASK,
665 WM8350_IM_SYS_WDOG_TO_EINT);
666 case WM8350_IRQ_UV_LDO4:
667 return wm8350_set_bits(wm8350,
668 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
669 WM8350_IM_UV_LDO4_EINT);
670 case WM8350_IRQ_UV_LDO3:
671 return wm8350_set_bits(wm8350,
672 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
673 WM8350_IM_UV_LDO3_EINT);
674 case WM8350_IRQ_UV_LDO2:
675 return wm8350_set_bits(wm8350,
676 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
677 WM8350_IM_UV_LDO2_EINT);
678 case WM8350_IRQ_UV_LDO1:
679 return wm8350_set_bits(wm8350,
680 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
681 WM8350_IM_UV_LDO1_EINT);
682 case WM8350_IRQ_UV_DC6:
683 return wm8350_set_bits(wm8350,
684 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
685 WM8350_IM_UV_DC6_EINT);
686 case WM8350_IRQ_UV_DC5:
687 return wm8350_set_bits(wm8350,
688 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
689 WM8350_IM_UV_DC5_EINT);
690 case WM8350_IRQ_UV_DC4:
691 return wm8350_set_bits(wm8350,
692 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
693 WM8350_IM_UV_DC4_EINT);
694 case WM8350_IRQ_UV_DC3:
695 return wm8350_set_bits(wm8350,
696 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
697 WM8350_IM_UV_DC3_EINT);
698 case WM8350_IRQ_UV_DC2:
699 return wm8350_set_bits(wm8350,
700 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
701 WM8350_IM_UV_DC2_EINT);
702 case WM8350_IRQ_UV_DC1:
703 return wm8350_set_bits(wm8350,
704 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
705 WM8350_IM_UV_DC1_EINT);
706 case WM8350_IRQ_OC_LS:
707 return wm8350_set_bits(wm8350,
708 WM8350_OVER_CURRENT_INT_STATUS_MASK,
709 WM8350_IM_OC_LS_EINT);
710 case WM8350_IRQ_EXT_USB_FB:
711 return wm8350_set_bits(wm8350,
712 WM8350_COMPARATOR_INT_STATUS_MASK,
713 WM8350_IM_EXT_USB_FB_EINT);
714 case WM8350_IRQ_EXT_WALL_FB:
715 return wm8350_set_bits(wm8350,
716 WM8350_COMPARATOR_INT_STATUS_MASK,
717 WM8350_IM_EXT_WALL_FB_EINT);
718 case WM8350_IRQ_EXT_BAT_FB:
719 return wm8350_set_bits(wm8350,
720 WM8350_COMPARATOR_INT_STATUS_MASK,
721 WM8350_IM_EXT_BAT_FB_EINT);
722 case WM8350_IRQ_CODEC_JCK_DET_L:
723 return wm8350_set_bits(wm8350,
724 WM8350_COMPARATOR_INT_STATUS_MASK,
725 WM8350_IM_CODEC_JCK_DET_L_EINT);
726 case WM8350_IRQ_CODEC_JCK_DET_R:
727 return wm8350_set_bits(wm8350,
728 WM8350_COMPARATOR_INT_STATUS_MASK,
729 WM8350_IM_CODEC_JCK_DET_R_EINT);
730 case WM8350_IRQ_CODEC_MICSCD:
731 return wm8350_set_bits(wm8350,
732 WM8350_COMPARATOR_INT_STATUS_MASK,
733 WM8350_IM_CODEC_MICSCD_EINT);
734 case WM8350_IRQ_CODEC_MICD:
735 return wm8350_set_bits(wm8350,
736 WM8350_COMPARATOR_INT_STATUS_MASK,
737 WM8350_IM_CODEC_MICD_EINT);
738 case WM8350_IRQ_WKUP_OFF_STATE:
739 return wm8350_set_bits(wm8350,
740 WM8350_COMPARATOR_INT_STATUS_MASK,
741 WM8350_IM_WKUP_OFF_STATE_EINT);
742 case WM8350_IRQ_WKUP_HIB_STATE:
743 return wm8350_set_bits(wm8350,
744 WM8350_COMPARATOR_INT_STATUS_MASK,
745 WM8350_IM_WKUP_HIB_STATE_EINT);
746 case WM8350_IRQ_WKUP_CONV_FAULT:
747 return wm8350_set_bits(wm8350,
748 WM8350_COMPARATOR_INT_STATUS_MASK,
749 WM8350_IM_WKUP_CONV_FAULT_EINT);
750 case WM8350_IRQ_WKUP_WDOG_RST:
751 return wm8350_set_bits(wm8350,
752 WM8350_COMPARATOR_INT_STATUS_MASK,
753 WM8350_IM_WKUP_OFF_STATE_EINT);
754 case WM8350_IRQ_WKUP_GP_PWR_ON:
755 return wm8350_set_bits(wm8350,
756 WM8350_COMPARATOR_INT_STATUS_MASK,
757 WM8350_IM_WKUP_GP_PWR_ON_EINT);
758 case WM8350_IRQ_WKUP_ONKEY:
759 return wm8350_set_bits(wm8350,
760 WM8350_COMPARATOR_INT_STATUS_MASK,
761 WM8350_IM_WKUP_ONKEY_EINT);
762 case WM8350_IRQ_WKUP_GP_WAKEUP:
763 return wm8350_set_bits(wm8350,
764 WM8350_COMPARATOR_INT_STATUS_MASK,
765 WM8350_IM_WKUP_GP_WAKEUP_EINT);
766 case WM8350_IRQ_GPIO(0):
767 return wm8350_set_bits(wm8350,
768 WM8350_GPIO_INT_STATUS_MASK,
769 WM8350_IM_GP0_EINT);
770 case WM8350_IRQ_GPIO(1):
771 return wm8350_set_bits(wm8350,
772 WM8350_GPIO_INT_STATUS_MASK,
773 WM8350_IM_GP1_EINT);
774 case WM8350_IRQ_GPIO(2):
775 return wm8350_set_bits(wm8350,
776 WM8350_GPIO_INT_STATUS_MASK,
777 WM8350_IM_GP2_EINT);
778 case WM8350_IRQ_GPIO(3):
779 return wm8350_set_bits(wm8350,
780 WM8350_GPIO_INT_STATUS_MASK,
781 WM8350_IM_GP3_EINT);
782 case WM8350_IRQ_GPIO(4):
783 return wm8350_set_bits(wm8350,
784 WM8350_GPIO_INT_STATUS_MASK,
785 WM8350_IM_GP4_EINT);
786 case WM8350_IRQ_GPIO(5):
787 return wm8350_set_bits(wm8350,
788 WM8350_GPIO_INT_STATUS_MASK,
789 WM8350_IM_GP5_EINT);
790 case WM8350_IRQ_GPIO(6):
791 return wm8350_set_bits(wm8350,
792 WM8350_GPIO_INT_STATUS_MASK,
793 WM8350_IM_GP6_EINT);
794 case WM8350_IRQ_GPIO(7):
795 return wm8350_set_bits(wm8350,
796 WM8350_GPIO_INT_STATUS_MASK,
797 WM8350_IM_GP7_EINT);
798 case WM8350_IRQ_GPIO(8):
799 return wm8350_set_bits(wm8350,
800 WM8350_GPIO_INT_STATUS_MASK,
801 WM8350_IM_GP8_EINT);
802 case WM8350_IRQ_GPIO(9):
803 return wm8350_set_bits(wm8350,
804 WM8350_GPIO_INT_STATUS_MASK,
805 WM8350_IM_GP9_EINT);
806 case WM8350_IRQ_GPIO(10):
807 return wm8350_set_bits(wm8350,
808 WM8350_GPIO_INT_STATUS_MASK,
809 WM8350_IM_GP10_EINT);
810 case WM8350_IRQ_GPIO(11):
811 return wm8350_set_bits(wm8350,
812 WM8350_GPIO_INT_STATUS_MASK,
813 WM8350_IM_GP11_EINT);
814 case WM8350_IRQ_GPIO(12):
815 return wm8350_set_bits(wm8350,
816 WM8350_GPIO_INT_STATUS_MASK,
817 WM8350_IM_GP12_EINT);
818 default:
819 dev_warn(wm8350->dev, "Attempting to mask unknown IRQ %d\n",
820 irq);
821 return -EINVAL;
822 }
823 return 0;
824}
825EXPORT_SYMBOL_GPL(wm8350_mask_irq);
826
827int wm8350_unmask_irq(struct wm8350 *wm8350, int irq)
828{
829 switch (irq) {
830 case WM8350_IRQ_CHG_BAT_HOT:
831 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
832 WM8350_IM_CHG_BAT_HOT_EINT);
833 case WM8350_IRQ_CHG_BAT_COLD:
834 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
835 WM8350_IM_CHG_BAT_COLD_EINT);
836 case WM8350_IRQ_CHG_BAT_FAIL:
837 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
838 WM8350_IM_CHG_BAT_FAIL_EINT);
839 case WM8350_IRQ_CHG_TO:
840 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
841 WM8350_IM_CHG_TO_EINT);
842 case WM8350_IRQ_CHG_END:
843 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
844 WM8350_IM_CHG_END_EINT);
845 case WM8350_IRQ_CHG_START:
846 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
847 WM8350_IM_CHG_START_EINT);
848 case WM8350_IRQ_CHG_FAST_RDY:
849 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
850 WM8350_IM_CHG_FAST_RDY_EINT);
851 case WM8350_IRQ_RTC_PER:
852 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
853 WM8350_IM_RTC_PER_EINT);
854 case WM8350_IRQ_RTC_SEC:
855 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
856 WM8350_IM_RTC_SEC_EINT);
857 case WM8350_IRQ_RTC_ALM:
858 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
859 WM8350_IM_RTC_ALM_EINT);
860 case WM8350_IRQ_CHG_VBATT_LT_3P9:
861 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
862 WM8350_IM_CHG_VBATT_LT_3P9_EINT);
863 case WM8350_IRQ_CHG_VBATT_LT_3P1:
864 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
865 WM8350_IM_CHG_VBATT_LT_3P1_EINT);
866 case WM8350_IRQ_CHG_VBATT_LT_2P85:
867 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_1_MASK,
868 WM8350_IM_CHG_VBATT_LT_2P85_EINT);
869 case WM8350_IRQ_CS1:
870 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
871 WM8350_IM_CS1_EINT);
872 case WM8350_IRQ_CS2:
873 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
874 WM8350_IM_CS2_EINT);
875 case WM8350_IRQ_USB_LIMIT:
876 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
877 WM8350_IM_USB_LIMIT_EINT);
878 case WM8350_IRQ_AUXADC_DATARDY:
879 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
880 WM8350_IM_AUXADC_DATARDY_EINT);
881 case WM8350_IRQ_AUXADC_DCOMP4:
882 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
883 WM8350_IM_AUXADC_DCOMP4_EINT);
884 case WM8350_IRQ_AUXADC_DCOMP3:
885 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
886 WM8350_IM_AUXADC_DCOMP3_EINT);
887 case WM8350_IRQ_AUXADC_DCOMP2:
888 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
889 WM8350_IM_AUXADC_DCOMP2_EINT);
890 case WM8350_IRQ_AUXADC_DCOMP1:
891 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
892 WM8350_IM_AUXADC_DCOMP1_EINT);
893 case WM8350_IRQ_SYS_HYST_COMP_FAIL:
894 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
895 WM8350_IM_SYS_HYST_COMP_FAIL_EINT);
896 case WM8350_IRQ_SYS_CHIP_GT115:
897 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
898 WM8350_IM_SYS_CHIP_GT115_EINT);
899 case WM8350_IRQ_SYS_CHIP_GT140:
900 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
901 WM8350_IM_SYS_CHIP_GT140_EINT);
902 case WM8350_IRQ_SYS_WDOG_TO:
903 return wm8350_clear_bits(wm8350, WM8350_INT_STATUS_2_MASK,
904 WM8350_IM_SYS_WDOG_TO_EINT);
905 case WM8350_IRQ_UV_LDO4:
906 return wm8350_clear_bits(wm8350,
907 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
908 WM8350_IM_UV_LDO4_EINT);
909 case WM8350_IRQ_UV_LDO3:
910 return wm8350_clear_bits(wm8350,
911 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
912 WM8350_IM_UV_LDO3_EINT);
913 case WM8350_IRQ_UV_LDO2:
914 return wm8350_clear_bits(wm8350,
915 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
916 WM8350_IM_UV_LDO2_EINT);
917 case WM8350_IRQ_UV_LDO1:
918 return wm8350_clear_bits(wm8350,
919 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
920 WM8350_IM_UV_LDO1_EINT);
921 case WM8350_IRQ_UV_DC6:
922 return wm8350_clear_bits(wm8350,
923 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
924 WM8350_IM_UV_DC6_EINT);
925 case WM8350_IRQ_UV_DC5:
926 return wm8350_clear_bits(wm8350,
927 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
928 WM8350_IM_UV_DC5_EINT);
929 case WM8350_IRQ_UV_DC4:
930 return wm8350_clear_bits(wm8350,
931 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
932 WM8350_IM_UV_DC4_EINT);
933 case WM8350_IRQ_UV_DC3:
934 return wm8350_clear_bits(wm8350,
935 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
936 WM8350_IM_UV_DC3_EINT);
937 case WM8350_IRQ_UV_DC2:
938 return wm8350_clear_bits(wm8350,
939 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
940 WM8350_IM_UV_DC2_EINT);
941 case WM8350_IRQ_UV_DC1:
942 return wm8350_clear_bits(wm8350,
943 WM8350_UNDER_VOLTAGE_INT_STATUS_MASK,
944 WM8350_IM_UV_DC1_EINT);
945 case WM8350_IRQ_OC_LS:
946 return wm8350_clear_bits(wm8350,
947 WM8350_OVER_CURRENT_INT_STATUS_MASK,
948 WM8350_IM_OC_LS_EINT);
949 case WM8350_IRQ_EXT_USB_FB:
950 return wm8350_clear_bits(wm8350,
951 WM8350_COMPARATOR_INT_STATUS_MASK,
952 WM8350_IM_EXT_USB_FB_EINT);
953 case WM8350_IRQ_EXT_WALL_FB:
954 return wm8350_clear_bits(wm8350,
955 WM8350_COMPARATOR_INT_STATUS_MASK,
956 WM8350_IM_EXT_WALL_FB_EINT);
957 case WM8350_IRQ_EXT_BAT_FB:
958 return wm8350_clear_bits(wm8350,
959 WM8350_COMPARATOR_INT_STATUS_MASK,
960 WM8350_IM_EXT_BAT_FB_EINT);
961 case WM8350_IRQ_CODEC_JCK_DET_L:
962 return wm8350_clear_bits(wm8350,
963 WM8350_COMPARATOR_INT_STATUS_MASK,
964 WM8350_IM_CODEC_JCK_DET_L_EINT);
965 case WM8350_IRQ_CODEC_JCK_DET_R:
966 return wm8350_clear_bits(wm8350,
967 WM8350_COMPARATOR_INT_STATUS_MASK,
968 WM8350_IM_CODEC_JCK_DET_R_EINT);
969 case WM8350_IRQ_CODEC_MICSCD:
970 return wm8350_clear_bits(wm8350,
971 WM8350_COMPARATOR_INT_STATUS_MASK,
972 WM8350_IM_CODEC_MICSCD_EINT);
973 case WM8350_IRQ_CODEC_MICD:
974 return wm8350_clear_bits(wm8350,
975 WM8350_COMPARATOR_INT_STATUS_MASK,
976 WM8350_IM_CODEC_MICD_EINT);
977 case WM8350_IRQ_WKUP_OFF_STATE:
978 return wm8350_clear_bits(wm8350,
979 WM8350_COMPARATOR_INT_STATUS_MASK,
980 WM8350_IM_WKUP_OFF_STATE_EINT);
981 case WM8350_IRQ_WKUP_HIB_STATE:
982 return wm8350_clear_bits(wm8350,
983 WM8350_COMPARATOR_INT_STATUS_MASK,
984 WM8350_IM_WKUP_HIB_STATE_EINT);
985 case WM8350_IRQ_WKUP_CONV_FAULT:
986 return wm8350_clear_bits(wm8350,
987 WM8350_COMPARATOR_INT_STATUS_MASK,
988 WM8350_IM_WKUP_CONV_FAULT_EINT);
989 case WM8350_IRQ_WKUP_WDOG_RST:
990 return wm8350_clear_bits(wm8350,
991 WM8350_COMPARATOR_INT_STATUS_MASK,
992 WM8350_IM_WKUP_OFF_STATE_EINT);
993 case WM8350_IRQ_WKUP_GP_PWR_ON:
994 return wm8350_clear_bits(wm8350,
995 WM8350_COMPARATOR_INT_STATUS_MASK,
996 WM8350_IM_WKUP_GP_PWR_ON_EINT);
997 case WM8350_IRQ_WKUP_ONKEY:
998 return wm8350_clear_bits(wm8350,
999 WM8350_COMPARATOR_INT_STATUS_MASK,
1000 WM8350_IM_WKUP_ONKEY_EINT);
1001 case WM8350_IRQ_WKUP_GP_WAKEUP:
1002 return wm8350_clear_bits(wm8350,
1003 WM8350_COMPARATOR_INT_STATUS_MASK,
1004 WM8350_IM_WKUP_GP_WAKEUP_EINT);
1005 case WM8350_IRQ_GPIO(0):
1006 return wm8350_clear_bits(wm8350,
1007 WM8350_GPIO_INT_STATUS_MASK,
1008 WM8350_IM_GP0_EINT);
1009 case WM8350_IRQ_GPIO(1):
1010 return wm8350_clear_bits(wm8350,
1011 WM8350_GPIO_INT_STATUS_MASK,
1012 WM8350_IM_GP1_EINT);
1013 case WM8350_IRQ_GPIO(2):
1014 return wm8350_clear_bits(wm8350,
1015 WM8350_GPIO_INT_STATUS_MASK,
1016 WM8350_IM_GP2_EINT);
1017 case WM8350_IRQ_GPIO(3):
1018 return wm8350_clear_bits(wm8350,
1019 WM8350_GPIO_INT_STATUS_MASK,
1020 WM8350_IM_GP3_EINT);
1021 case WM8350_IRQ_GPIO(4):
1022 return wm8350_clear_bits(wm8350,
1023 WM8350_GPIO_INT_STATUS_MASK,
1024 WM8350_IM_GP4_EINT);
1025 case WM8350_IRQ_GPIO(5):
1026 return wm8350_clear_bits(wm8350,
1027 WM8350_GPIO_INT_STATUS_MASK,
1028 WM8350_IM_GP5_EINT);
1029 case WM8350_IRQ_GPIO(6):
1030 return wm8350_clear_bits(wm8350,
1031 WM8350_GPIO_INT_STATUS_MASK,
1032 WM8350_IM_GP6_EINT);
1033 case WM8350_IRQ_GPIO(7):
1034 return wm8350_clear_bits(wm8350,
1035 WM8350_GPIO_INT_STATUS_MASK,
1036 WM8350_IM_GP7_EINT);
1037 case WM8350_IRQ_GPIO(8):
1038 return wm8350_clear_bits(wm8350,
1039 WM8350_GPIO_INT_STATUS_MASK,
1040 WM8350_IM_GP8_EINT);
1041 case WM8350_IRQ_GPIO(9):
1042 return wm8350_clear_bits(wm8350,
1043 WM8350_GPIO_INT_STATUS_MASK,
1044 WM8350_IM_GP9_EINT);
1045 case WM8350_IRQ_GPIO(10):
1046 return wm8350_clear_bits(wm8350,
1047 WM8350_GPIO_INT_STATUS_MASK,
1048 WM8350_IM_GP10_EINT);
1049 case WM8350_IRQ_GPIO(11):
1050 return wm8350_clear_bits(wm8350,
1051 WM8350_GPIO_INT_STATUS_MASK,
1052 WM8350_IM_GP11_EINT);
1053 case WM8350_IRQ_GPIO(12):
1054 return wm8350_clear_bits(wm8350,
1055 WM8350_GPIO_INT_STATUS_MASK,
1056 WM8350_IM_GP12_EINT);
1057 default:
1058 dev_warn(wm8350->dev, "Attempting to unmask unknown IRQ %d\n",
1059 irq);
1060 return -EINVAL;
1061 }
1062 return 0;
1063}
1064EXPORT_SYMBOL_GPL(wm8350_unmask_irq);
1065
1066/*
1067 * Cache is always host endian.
1068 */
1069static int wm8350_create_cache(struct wm8350 *wm8350, int mode)
1070{
1071 int i, ret = 0;
1072 u16 value;
1073 const u16 *reg_map;
1074
1075 switch (mode) {
1076#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_0
1077 case 0:
1078 reg_map = wm8350_mode0_defaults;
1079 break;
1080#endif
1081#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_1
1082 case 1:
1083 reg_map = wm8350_mode1_defaults;
1084 break;
1085#endif
1086#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_2
1087 case 2:
1088 reg_map = wm8350_mode2_defaults;
1089 break;
1090#endif
1091#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_3
1092 case 3:
1093 reg_map = wm8350_mode3_defaults;
1094 break;
1095#endif
1096 default:
1097 dev_err(wm8350->dev, "Configuration mode %d not supported\n",
1098 mode);
1099 return -EINVAL;
1100 }
1101
1102 wm8350->reg_cache =
1103 kzalloc(sizeof(u16) * (WM8350_MAX_REGISTER + 1), GFP_KERNEL);
1104 if (wm8350->reg_cache == NULL)
1105 return -ENOMEM;
1106
1107 /* Read the initial cache state back from the device - this is
1108 * a PMIC so the device many not be in a virgin state and we
1109 * can't rely on the silicon values.
1110 */
1111 for (i = 0; i < WM8350_MAX_REGISTER; i++) {
1112 /* audio register range */
1113 if (wm8350_reg_io_map[i].readable &&
1114 (i < WM8350_CLOCK_CONTROL_1 || i > WM8350_AIF_TEST)) {
1115 ret = wm8350->read_dev(wm8350, i, 2, (char *)&value);
1116 if (ret < 0) {
1117 dev_err(wm8350->dev,
1118 "failed to read initial cache value\n");
1119 goto out;
1120 }
1121 value = be16_to_cpu(value);
1122 value &= wm8350_reg_io_map[i].readable;
1123 wm8350->reg_cache[i] = value;
1124 } else
1125 wm8350->reg_cache[i] = reg_map[i];
1126 }
1127
1128out:
1129 return ret;
1130}
1131EXPORT_SYMBOL_GPL(wm8350_create_cache);
1132
1133/*
1134 * Register a client device. This is non-fatal since there is no need to
1135 * fail the entire device init due to a single platform device failing.
1136 */
1137static void wm8350_client_dev_register(struct wm8350 *wm8350,
1138 const char *name,
1139 struct platform_device **pdev)
1140{
1141 int ret;
1142
1143 *pdev = platform_device_alloc(name, -1);
1144 if (pdev == NULL) {
1145 dev_err(wm8350->dev, "Failed to allocate %s\n", name);
1146 return;
1147 }
1148
1149 (*pdev)->dev.parent = wm8350->dev;
1150 platform_set_drvdata(*pdev, wm8350);
1151 ret = platform_device_add(*pdev);
1152 if (ret != 0) {
1153 dev_err(wm8350->dev, "Failed to register %s: %d\n", name, ret);
1154 platform_device_put(*pdev);
1155 *pdev = NULL;
1156 }
1157}
1158
1159int wm8350_device_init(struct wm8350 *wm8350, int irq,
1160 struct wm8350_platform_data *pdata)
1161{
1162 int ret = -EINVAL;
1163 u16 id1, id2, mask, mode;
1164
1165 /* get WM8350 revision and config mode */
1166 wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1);
1167 wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2);
1168
1169 id1 = be16_to_cpu(id1);
1170 id2 = be16_to_cpu(id2);
1171
1172 if (id1 == 0x6143) {
1173 switch ((id2 & WM8350_CHIP_REV_MASK) >> 12) {
1174 case WM8350_REV_E:
1175 dev_info(wm8350->dev, "Found Rev E device\n");
1176 wm8350->rev = WM8350_REV_E;
1177 break;
1178 case WM8350_REV_F:
1179 dev_info(wm8350->dev, "Found Rev F device\n");
1180 wm8350->rev = WM8350_REV_F;
1181 break;
1182 case WM8350_REV_G:
1183 dev_info(wm8350->dev, "Found Rev G device\n");
1184 wm8350->rev = WM8350_REV_G;
1185 break;
1186 default:
1187 /* For safety we refuse to run on unknown hardware */
1188 dev_info(wm8350->dev, "Found unknown rev\n");
1189 ret = -ENODEV;
1190 goto err;
1191 }
1192 } else {
1193 dev_info(wm8350->dev, "Device with ID %x is not a WM8350\n",
1194 id1);
1195 ret = -ENODEV;
1196 goto err;
1197 }
1198
1199 mode = id2 & WM8350_CONF_STS_MASK >> 10;
1200 mask = id2 & WM8350_CUST_ID_MASK;
1201 dev_info(wm8350->dev, "Config mode %d, ROM mask %d\n", mode, mask);
1202
1203 ret = wm8350_create_cache(wm8350, mode);
1204 if (ret < 0) {
1205 printk(KERN_ERR "wm8350: failed to create register cache\n");
1206 return ret;
1207 }
1208
1209 if (pdata->init) {
1210 ret = pdata->init(wm8350);
1211 if (ret != 0) {
1212 dev_err(wm8350->dev, "Platform init() failed: %d\n",
1213 ret);
1214 goto err;
1215 }
1216 }
1217
1218 mutex_init(&wm8350->irq_mutex);
1219 INIT_WORK(&wm8350->irq_work, wm8350_irq_worker);
1220 if (irq != NO_IRQ) {
1221 ret = request_irq(irq, wm8350_irq, 0,
1222 "wm8350", wm8350);
1223 if (ret != 0) {
1224 dev_err(wm8350->dev, "Failed to request IRQ: %d\n",
1225 ret);
1226 goto err;
1227 }
1228 } else {
1229 dev_err(wm8350->dev, "No IRQ configured\n");
1230 goto err;
1231 }
1232 wm8350->chip_irq = irq;
1233
1234 wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0x0);
1235
1236 wm8350_client_dev_register(wm8350, "wm8350-codec",
1237 &(wm8350->codec.pdev));
1238 wm8350_client_dev_register(wm8350, "wm8350-gpio",
1239 &(wm8350->gpio.pdev));
1240 wm8350_client_dev_register(wm8350, "wm8350-power",
1241 &(wm8350->power.pdev));
1242 wm8350_client_dev_register(wm8350, "wm8350-rtc", &(wm8350->rtc.pdev));
1243 wm8350_client_dev_register(wm8350, "wm8350-wdt", &(wm8350->wdt.pdev));
1244
1245 return 0;
1246
1247err:
1248 kfree(wm8350->reg_cache);
1249 return ret;
1250}
1251EXPORT_SYMBOL_GPL(wm8350_device_init);
1252
1253void wm8350_device_exit(struct wm8350 *wm8350)
1254{
1255 int i;
1256
1257 for (i = 0; i < ARRAY_SIZE(wm8350->pmic.pdev); i++)
1258 platform_device_unregister(wm8350->pmic.pdev[i]);
1259
1260 platform_device_unregister(wm8350->wdt.pdev);
1261 platform_device_unregister(wm8350->rtc.pdev);
1262 platform_device_unregister(wm8350->power.pdev);
1263 platform_device_unregister(wm8350->gpio.pdev);
1264 platform_device_unregister(wm8350->codec.pdev);
1265
1266 free_irq(wm8350->chip_irq, wm8350);
1267 flush_work(&wm8350->irq_work);
1268 kfree(wm8350->reg_cache);
1269}
1270EXPORT_SYMBOL_GPL(wm8350_device_exit);
1271
1272MODULE_DESCRIPTION("WM8350 AudioPlus PMIC core driver");
1273MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/wm8350-gpio.c b/drivers/mfd/wm8350-gpio.c
new file mode 100644
index 000000000000..ebf99bef392f
--- /dev/null
+++ b/drivers/mfd/wm8350-gpio.c
@@ -0,0 +1,222 @@
1/*
2 * wm8350-core.c -- Device access for Wolfson WM8350
3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/errno.h>
18
19#include <linux/mfd/wm8350/core.h>
20#include <linux/mfd/wm8350/gpio.h>
21#include <linux/mfd/wm8350/pmic.h>
22
23static int gpio_set_dir(struct wm8350 *wm8350, int gpio, int dir)
24{
25 int ret;
26
27 wm8350_reg_unlock(wm8350);
28 if (dir == WM8350_GPIO_DIR_OUT)
29 ret = wm8350_clear_bits(wm8350,
30 WM8350_GPIO_CONFIGURATION_I_O,
31 1 << gpio);
32 else
33 ret = wm8350_set_bits(wm8350,
34 WM8350_GPIO_CONFIGURATION_I_O,
35 1 << gpio);
36 wm8350_reg_lock(wm8350);
37 return ret;
38}
39
40static int gpio_set_debounce(struct wm8350 *wm8350, int gpio, int db)
41{
42 if (db == WM8350_GPIO_DEBOUNCE_ON)
43 return wm8350_set_bits(wm8350, WM8350_GPIO_DEBOUNCE,
44 1 << gpio);
45 else
46 return wm8350_clear_bits(wm8350,
47 WM8350_GPIO_DEBOUNCE, 1 << gpio);
48}
49
50static int gpio_set_func(struct wm8350 *wm8350, int gpio, int func)
51{
52 u16 reg;
53
54 wm8350_reg_unlock(wm8350);
55 switch (gpio) {
56 case 0:
57 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_1)
58 & ~WM8350_GP0_FN_MASK;
59 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_1,
60 reg | ((func & 0xf) << 0));
61 break;
62 case 1:
63 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_1)
64 & ~WM8350_GP1_FN_MASK;
65 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_1,
66 reg | ((func & 0xf) << 4));
67 break;
68 case 2:
69 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_1)
70 & ~WM8350_GP2_FN_MASK;
71 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_1,
72 reg | ((func & 0xf) << 8));
73 break;
74 case 3:
75 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_1)
76 & ~WM8350_GP3_FN_MASK;
77 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_1,
78 reg | ((func & 0xf) << 12));
79 break;
80 case 4:
81 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_2)
82 & ~WM8350_GP4_FN_MASK;
83 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_2,
84 reg | ((func & 0xf) << 0));
85 break;
86 case 5:
87 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_2)
88 & ~WM8350_GP5_FN_MASK;
89 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_2,
90 reg | ((func & 0xf) << 4));
91 break;
92 case 6:
93 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_2)
94 & ~WM8350_GP6_FN_MASK;
95 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_2,
96 reg | ((func & 0xf) << 8));
97 break;
98 case 7:
99 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_2)
100 & ~WM8350_GP7_FN_MASK;
101 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_2,
102 reg | ((func & 0xf) << 12));
103 break;
104 case 8:
105 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_3)
106 & ~WM8350_GP8_FN_MASK;
107 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_3,
108 reg | ((func & 0xf) << 0));
109 break;
110 case 9:
111 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_3)
112 & ~WM8350_GP9_FN_MASK;
113 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_3,
114 reg | ((func & 0xf) << 4));
115 break;
116 case 10:
117 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_3)
118 & ~WM8350_GP10_FN_MASK;
119 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_3,
120 reg | ((func & 0xf) << 8));
121 break;
122 case 11:
123 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_3)
124 & ~WM8350_GP11_FN_MASK;
125 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_3,
126 reg | ((func & 0xf) << 12));
127 break;
128 case 12:
129 reg = wm8350_reg_read(wm8350, WM8350_GPIO_FUNCTION_SELECT_4)
130 & ~WM8350_GP12_FN_MASK;
131 wm8350_reg_write(wm8350, WM8350_GPIO_FUNCTION_SELECT_4,
132 reg | ((func & 0xf) << 0));
133 break;
134 default:
135 wm8350_reg_lock(wm8350);
136 return -EINVAL;
137 }
138
139 wm8350_reg_lock(wm8350);
140 return 0;
141}
142
143static int gpio_set_pull_up(struct wm8350 *wm8350, int gpio, int up)
144{
145 if (up)
146 return wm8350_set_bits(wm8350,
147 WM8350_GPIO_PIN_PULL_UP_CONTROL,
148 1 << gpio);
149 else
150 return wm8350_clear_bits(wm8350,
151 WM8350_GPIO_PIN_PULL_UP_CONTROL,
152 1 << gpio);
153}
154
155static int gpio_set_pull_down(struct wm8350 *wm8350, int gpio, int down)
156{
157 if (down)
158 return wm8350_set_bits(wm8350,
159 WM8350_GPIO_PULL_DOWN_CONTROL,
160 1 << gpio);
161 else
162 return wm8350_clear_bits(wm8350,
163 WM8350_GPIO_PULL_DOWN_CONTROL,
164 1 << gpio);
165}
166
167static int gpio_set_polarity(struct wm8350 *wm8350, int gpio, int pol)
168{
169 if (pol == WM8350_GPIO_ACTIVE_HIGH)
170 return wm8350_set_bits(wm8350,
171 WM8350_GPIO_PIN_POLARITY_TYPE,
172 1 << gpio);
173 else
174 return wm8350_clear_bits(wm8350,
175 WM8350_GPIO_PIN_POLARITY_TYPE,
176 1 << gpio);
177}
178
179static int gpio_set_invert(struct wm8350 *wm8350, int gpio, int invert)
180{
181 if (invert == WM8350_GPIO_INVERT_ON)
182 return wm8350_set_bits(wm8350, WM8350_GPIO_INT_MODE, 1 << gpio);
183 else
184 return wm8350_clear_bits(wm8350,
185 WM8350_GPIO_INT_MODE, 1 << gpio);
186}
187
188int wm8350_gpio_config(struct wm8350 *wm8350, int gpio, int dir, int func,
189 int pol, int pull, int invert, int debounce)
190{
191 /* make sure we never pull up and down at the same time */
192 if (pull == WM8350_GPIO_PULL_NONE) {
193 if (gpio_set_pull_up(wm8350, gpio, 0))
194 goto err;
195 if (gpio_set_pull_down(wm8350, gpio, 0))
196 goto err;
197 } else if (pull == WM8350_GPIO_PULL_UP) {
198 if (gpio_set_pull_down(wm8350, gpio, 0))
199 goto err;
200 if (gpio_set_pull_up(wm8350, gpio, 1))
201 goto err;
202 } else if (pull == WM8350_GPIO_PULL_DOWN) {
203 if (gpio_set_pull_up(wm8350, gpio, 0))
204 goto err;
205 if (gpio_set_pull_down(wm8350, gpio, 1))
206 goto err;
207 }
208
209 if (gpio_set_invert(wm8350, gpio, invert))
210 goto err;
211 if (gpio_set_polarity(wm8350, gpio, pol))
212 goto err;
213 if (gpio_set_debounce(wm8350, gpio, debounce))
214 goto err;
215 if (gpio_set_dir(wm8350, gpio, dir))
216 goto err;
217 return gpio_set_func(wm8350, gpio, func);
218
219err:
220 return -EIO;
221}
222EXPORT_SYMBOL_GPL(wm8350_gpio_config);
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
new file mode 100644
index 000000000000..8dfe21bb3bd1
--- /dev/null
+++ b/drivers/mfd/wm8350-i2c.c
@@ -0,0 +1,120 @@
1/*
2 * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC
3 *
4 * This driver defines and configures the WM8350 for the Freescale i.MX32ADS.
5 *
6 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
7 *
8 * Author: Liam Girdwood
9 * linux@wolfsonmicro.com
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17
18#include <linux/module.h>
19#include <linux/moduleparam.h>
20#include <linux/init.h>
21#include <linux/i2c.h>
22#include <linux/platform_device.h>
23#include <linux/mfd/wm8350/core.h>
24
25static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg,
26 int bytes, void *dest)
27{
28 int ret;
29
30 ret = i2c_master_send(wm8350->i2c_client, &reg, 1);
31 if (ret < 0)
32 return ret;
33 return i2c_master_recv(wm8350->i2c_client, dest, bytes);
34}
35
36static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg,
37 int bytes, void *src)
38{
39 /* we add 1 byte for device register */
40 u8 msg[(WM8350_MAX_REGISTER << 1) + 1];
41
42 if (bytes > ((WM8350_MAX_REGISTER << 1) + 1))
43 return -EINVAL;
44
45 msg[0] = reg;
46 memcpy(&msg[1], src, bytes);
47 return i2c_master_send(wm8350->i2c_client, msg, bytes + 1);
48}
49
50static int wm8350_i2c_probe(struct i2c_client *i2c,
51 const struct i2c_device_id *id)
52{
53 struct wm8350 *wm8350;
54 int ret = 0;
55
56 wm8350 = kzalloc(sizeof(struct wm8350), GFP_KERNEL);
57 if (wm8350 == NULL) {
58 kfree(i2c);
59 return -ENOMEM;
60 }
61
62 i2c_set_clientdata(i2c, wm8350);
63 wm8350->dev = &i2c->dev;
64 wm8350->i2c_client = i2c;
65 wm8350->read_dev = wm8350_i2c_read_device;
66 wm8350->write_dev = wm8350_i2c_write_device;
67
68 ret = wm8350_device_init(wm8350, i2c->irq, i2c->dev.platform_data);
69 if (ret < 0)
70 goto err;
71
72 return ret;
73
74err:
75 kfree(wm8350);
76 return ret;
77}
78
79static int wm8350_i2c_remove(struct i2c_client *i2c)
80{
81 struct wm8350 *wm8350 = i2c_get_clientdata(i2c);
82
83 wm8350_device_exit(wm8350);
84 kfree(wm8350);
85
86 return 0;
87}
88
89static const struct i2c_device_id wm8350_i2c_id[] = {
90 { "wm8350", 0 },
91 { }
92};
93MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id);
94
95
96static struct i2c_driver wm8350_i2c_driver = {
97 .driver = {
98 .name = "wm8350",
99 .owner = THIS_MODULE,
100 },
101 .probe = wm8350_i2c_probe,
102 .remove = wm8350_i2c_remove,
103 .id_table = wm8350_i2c_id,
104};
105
106static int __init wm8350_i2c_init(void)
107{
108 return i2c_add_driver(&wm8350_i2c_driver);
109}
110/* init early so consumer devices can complete system boot */
111subsys_initcall(wm8350_i2c_init);
112
113static void __exit wm8350_i2c_exit(void)
114{
115 i2c_del_driver(&wm8350_i2c_driver);
116}
117module_exit(wm8350_i2c_exit);
118
119MODULE_DESCRIPTION("I2C support for the WM8350 AudioPlus PMIC");
120MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
new file mode 100644
index 000000000000..974678db22cd
--- /dev/null
+++ b/drivers/mfd/wm8350-regmap.c
@@ -0,0 +1,1347 @@
1/*
2 * wm8350-regmap.c -- Wolfson Microelectronics WM8350 register map
3 *
4 * This file splits out the tables describing the defaults and access
5 * status of the WM8350 registers since they are rather large.
6 *
7 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
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
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15#include <linux/mfd/wm8350/core.h>
16
17#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_0
18
19#undef WM8350_HAVE_CONFIG_MODE
20#define WM8350_HAVE_CONFIG_MODE
21
22const u16 wm8350_mode0_defaults[] = {
23 0x17FF, /* R0 - Reset/ID */
24 0x1000, /* R1 - ID */
25 0x0000, /* R2 */
26 0x1002, /* R3 - System Control 1 */
27 0x0004, /* R4 - System Control 2 */
28 0x0000, /* R5 - System Hibernate */
29 0x8A00, /* R6 - Interface Control */
30 0x0000, /* R7 */
31 0x8000, /* R8 - Power mgmt (1) */
32 0x0000, /* R9 - Power mgmt (2) */
33 0x0000, /* R10 - Power mgmt (3) */
34 0x2000, /* R11 - Power mgmt (4) */
35 0x0E00, /* R12 - Power mgmt (5) */
36 0x0000, /* R13 - Power mgmt (6) */
37 0x0000, /* R14 - Power mgmt (7) */
38 0x0000, /* R15 */
39 0x0000, /* R16 - RTC Seconds/Minutes */
40 0x0100, /* R17 - RTC Hours/Day */
41 0x0101, /* R18 - RTC Date/Month */
42 0x1400, /* R19 - RTC Year */
43 0x0000, /* R20 - Alarm Seconds/Minutes */
44 0x0000, /* R21 - Alarm Hours/Day */
45 0x0000, /* R22 - Alarm Date/Month */
46 0x0320, /* R23 - RTC Time Control */
47 0x0000, /* R24 - System Interrupts */
48 0x0000, /* R25 - Interrupt Status 1 */
49 0x0000, /* R26 - Interrupt Status 2 */
50 0x0000, /* R27 - Power Up Interrupt Status */
51 0x0000, /* R28 - Under Voltage Interrupt status */
52 0x0000, /* R29 - Over Current Interrupt status */
53 0x0000, /* R30 - GPIO Interrupt Status */
54 0x0000, /* R31 - Comparator Interrupt Status */
55 0x3FFF, /* R32 - System Interrupts Mask */
56 0x0000, /* R33 - Interrupt Status 1 Mask */
57 0x0000, /* R34 - Interrupt Status 2 Mask */
58 0x0000, /* R35 - Power Up Interrupt Status Mask */
59 0x0000, /* R36 - Under Voltage Interrupt status Mask */
60 0x0000, /* R37 - Over Current Interrupt status Mask */
61 0x0000, /* R38 - GPIO Interrupt Status Mask */
62 0x0000, /* R39 - Comparator Interrupt Status Mask */
63 0x0040, /* R40 - Clock Control 1 */
64 0x0000, /* R41 - Clock Control 2 */
65 0x3B00, /* R42 - FLL Control 1 */
66 0x7086, /* R43 - FLL Control 2 */
67 0xC226, /* R44 - FLL Control 3 */
68 0x0000, /* R45 - FLL Control 4 */
69 0x0000, /* R46 */
70 0x0000, /* R47 */
71 0x0000, /* R48 - DAC Control */
72 0x0000, /* R49 */
73 0x00C0, /* R50 - DAC Digital Volume L */
74 0x00C0, /* R51 - DAC Digital Volume R */
75 0x0000, /* R52 */
76 0x0040, /* R53 - DAC LR Rate */
77 0x0000, /* R54 - DAC Clock Control */
78 0x0000, /* R55 */
79 0x0000, /* R56 */
80 0x0000, /* R57 */
81 0x4000, /* R58 - DAC Mute */
82 0x0000, /* R59 - DAC Mute Volume */
83 0x0000, /* R60 - DAC Side */
84 0x0000, /* R61 */
85 0x0000, /* R62 */
86 0x0000, /* R63 */
87 0x8000, /* R64 - ADC Control */
88 0x0000, /* R65 */
89 0x00C0, /* R66 - ADC Digital Volume L */
90 0x00C0, /* R67 - ADC Digital Volume R */
91 0x0000, /* R68 - ADC Divider */
92 0x0000, /* R69 */
93 0x0040, /* R70 - ADC LR Rate */
94 0x0000, /* R71 */
95 0x0303, /* R72 - Input Control */
96 0x0000, /* R73 - IN3 Input Control */
97 0x0000, /* R74 - Mic Bias Control */
98 0x0000, /* R75 */
99 0x0000, /* R76 - Output Control */
100 0x0000, /* R77 - Jack Detect */
101 0x0000, /* R78 - Anti Pop Control */
102 0x0000, /* R79 */
103 0x0040, /* R80 - Left Input Volume */
104 0x0040, /* R81 - Right Input Volume */
105 0x0000, /* R82 */
106 0x0000, /* R83 */
107 0x0000, /* R84 */
108 0x0000, /* R85 */
109 0x0000, /* R86 */
110 0x0000, /* R87 */
111 0x0800, /* R88 - Left Mixer Control */
112 0x1000, /* R89 - Right Mixer Control */
113 0x0000, /* R90 */
114 0x0000, /* R91 */
115 0x0000, /* R92 - OUT3 Mixer Control */
116 0x0000, /* R93 - OUT4 Mixer Control */
117 0x0000, /* R94 */
118 0x0000, /* R95 */
119 0x0000, /* R96 - Output Left Mixer Volume */
120 0x0000, /* R97 - Output Right Mixer Volume */
121 0x0000, /* R98 - Input Mixer Volume L */
122 0x0000, /* R99 - Input Mixer Volume R */
123 0x0000, /* R100 - Input Mixer Volume */
124 0x0000, /* R101 */
125 0x0000, /* R102 */
126 0x0000, /* R103 */
127 0x00E4, /* R104 - LOUT1 Volume */
128 0x00E4, /* R105 - ROUT1 Volume */
129 0x00E4, /* R106 - LOUT2 Volume */
130 0x02E4, /* R107 - ROUT2 Volume */
131 0x0000, /* R108 */
132 0x0000, /* R109 */
133 0x0000, /* R110 */
134 0x0000, /* R111 - BEEP Volume */
135 0x0A00, /* R112 - AI Formating */
136 0x0000, /* R113 - ADC DAC COMP */
137 0x0020, /* R114 - AI ADC Control */
138 0x0020, /* R115 - AI DAC Control */
139 0x0000, /* R116 - AIF Test */
140 0x0000, /* R117 */
141 0x0000, /* R118 */
142 0x0000, /* R119 */
143 0x0000, /* R120 */
144 0x0000, /* R121 */
145 0x0000, /* R122 */
146 0x0000, /* R123 */
147 0x0000, /* R124 */
148 0x0000, /* R125 */
149 0x0000, /* R126 */
150 0x0000, /* R127 */
151 0x1FFF, /* R128 - GPIO Debounce */
152 0x0000, /* R129 - GPIO Pin pull up Control */
153 0x03FC, /* R130 - GPIO Pull down Control */
154 0x0000, /* R131 - GPIO Interrupt Mode */
155 0x0000, /* R132 */
156 0x0000, /* R133 - GPIO Control */
157 0x0FFC, /* R134 - GPIO Configuration (i/o) */
158 0x0FFC, /* R135 - GPIO Pin Polarity / Type */
159 0x0000, /* R136 */
160 0x0000, /* R137 */
161 0x0000, /* R138 */
162 0x0000, /* R139 */
163 0x0013, /* R140 - GPIO Function Select 1 */
164 0x0000, /* R141 - GPIO Function Select 2 */
165 0x0000, /* R142 - GPIO Function Select 3 */
166 0x0003, /* R143 - GPIO Function Select 4 */
167 0x0000, /* R144 - Digitiser Control (1) */
168 0x0002, /* R145 - Digitiser Control (2) */
169 0x0000, /* R146 */
170 0x0000, /* R147 */
171 0x0000, /* R148 */
172 0x0000, /* R149 */
173 0x0000, /* R150 */
174 0x0000, /* R151 */
175 0x7000, /* R152 - AUX1 Readback */
176 0x7000, /* R153 - AUX2 Readback */
177 0x7000, /* R154 - AUX3 Readback */
178 0x7000, /* R155 - AUX4 Readback */
179 0x0000, /* R156 - USB Voltage Readback */
180 0x0000, /* R157 - LINE Voltage Readback */
181 0x0000, /* R158 - BATT Voltage Readback */
182 0x0000, /* R159 - Chip Temp Readback */
183 0x0000, /* R160 */
184 0x0000, /* R161 */
185 0x0000, /* R162 */
186 0x0000, /* R163 - Generic Comparator Control */
187 0x0000, /* R164 - Generic comparator 1 */
188 0x0000, /* R165 - Generic comparator 2 */
189 0x0000, /* R166 - Generic comparator 3 */
190 0x0000, /* R167 - Generic comparator 4 */
191 0xA00F, /* R168 - Battery Charger Control 1 */
192 0x0B06, /* R169 - Battery Charger Control 2 */
193 0x0000, /* R170 - Battery Charger Control 3 */
194 0x0000, /* R171 */
195 0x0000, /* R172 - Current Sink Driver A */
196 0x0000, /* R173 - CSA Flash control */
197 0x0000, /* R174 - Current Sink Driver B */
198 0x0000, /* R175 - CSB Flash control */
199 0x0000, /* R176 - DCDC/LDO requested */
200 0x002D, /* R177 - DCDC Active options */
201 0x0000, /* R178 - DCDC Sleep options */
202 0x0025, /* R179 - Power-check comparator */
203 0x000E, /* R180 - DCDC1 Control */
204 0x0000, /* R181 - DCDC1 Timeouts */
205 0x1006, /* R182 - DCDC1 Low Power */
206 0x0018, /* R183 - DCDC2 Control */
207 0x0000, /* R184 - DCDC2 Timeouts */
208 0x0000, /* R185 */
209 0x0000, /* R186 - DCDC3 Control */
210 0x0000, /* R187 - DCDC3 Timeouts */
211 0x0006, /* R188 - DCDC3 Low Power */
212 0x0000, /* R189 - DCDC4 Control */
213 0x0000, /* R190 - DCDC4 Timeouts */
214 0x0006, /* R191 - DCDC4 Low Power */
215 0x0008, /* R192 - DCDC5 Control */
216 0x0000, /* R193 - DCDC5 Timeouts */
217 0x0000, /* R194 */
218 0x0000, /* R195 - DCDC6 Control */
219 0x0000, /* R196 - DCDC6 Timeouts */
220 0x0006, /* R197 - DCDC6 Low Power */
221 0x0000, /* R198 */
222 0x0003, /* R199 - Limit Switch Control */
223 0x001C, /* R200 - LDO1 Control */
224 0x0000, /* R201 - LDO1 Timeouts */
225 0x001C, /* R202 - LDO1 Low Power */
226 0x001B, /* R203 - LDO2 Control */
227 0x0000, /* R204 - LDO2 Timeouts */
228 0x001C, /* R205 - LDO2 Low Power */
229 0x001B, /* R206 - LDO3 Control */
230 0x0000, /* R207 - LDO3 Timeouts */
231 0x001C, /* R208 - LDO3 Low Power */
232 0x001B, /* R209 - LDO4 Control */
233 0x0000, /* R210 - LDO4 Timeouts */
234 0x001C, /* R211 - LDO4 Low Power */
235 0x0000, /* R212 */
236 0x0000, /* R213 */
237 0x0000, /* R214 */
238 0x0000, /* R215 - VCC_FAULT Masks */
239 0x001F, /* R216 - Main Bandgap Control */
240 0x0000, /* R217 - OSC Control */
241 0x9000, /* R218 - RTC Tick Control */
242 0x0000, /* R219 */
243 0x4000, /* R220 - RAM BIST 1 */
244 0x0000, /* R221 */
245 0x0000, /* R222 */
246 0x0000, /* R223 */
247 0x0000, /* R224 */
248 0x0000, /* R225 - DCDC/LDO status */
249 0x0000, /* R226 */
250 0x0000, /* R227 */
251 0x0000, /* R228 */
252 0x0000, /* R229 */
253 0xE000, /* R230 - GPIO Pin Status */
254 0x0000, /* R231 */
255 0x0000, /* R232 */
256 0x0000, /* R233 */
257 0x0000, /* R234 */
258 0x0000, /* R235 */
259 0x0000, /* R236 */
260 0x0000, /* R237 */
261 0x0000, /* R238 */
262 0x0000, /* R239 */
263 0x0000, /* R240 */
264 0x0000, /* R241 */
265 0x0000, /* R242 */
266 0x0000, /* R243 */
267 0x0000, /* R244 */
268 0x0000, /* R245 */
269 0x0000, /* R246 */
270 0x0000, /* R247 */
271 0x0000, /* R248 */
272 0x0000, /* R249 */
273 0x0000, /* R250 */
274 0x0000, /* R251 */
275 0x0000, /* R252 */
276 0x0000, /* R253 */
277 0x0000, /* R254 */
278 0x0000, /* R255 */
279};
280#endif
281
282#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_1
283
284#undef WM8350_HAVE_CONFIG_MODE
285#define WM8350_HAVE_CONFIG_MODE
286
287const u16 wm8350_mode1_defaults[] = {
288 0x17FF, /* R0 - Reset/ID */
289 0x1000, /* R1 - ID */
290 0x0000, /* R2 */
291 0x1002, /* R3 - System Control 1 */
292 0x0014, /* R4 - System Control 2 */
293 0x0000, /* R5 - System Hibernate */
294 0x8A00, /* R6 - Interface Control */
295 0x0000, /* R7 */
296 0x8000, /* R8 - Power mgmt (1) */
297 0x0000, /* R9 - Power mgmt (2) */
298 0x0000, /* R10 - Power mgmt (3) */
299 0x2000, /* R11 - Power mgmt (4) */
300 0x0E00, /* R12 - Power mgmt (5) */
301 0x0000, /* R13 - Power mgmt (6) */
302 0x0000, /* R14 - Power mgmt (7) */
303 0x0000, /* R15 */
304 0x0000, /* R16 - RTC Seconds/Minutes */
305 0x0100, /* R17 - RTC Hours/Day */
306 0x0101, /* R18 - RTC Date/Month */
307 0x1400, /* R19 - RTC Year */
308 0x0000, /* R20 - Alarm Seconds/Minutes */
309 0x0000, /* R21 - Alarm Hours/Day */
310 0x0000, /* R22 - Alarm Date/Month */
311 0x0320, /* R23 - RTC Time Control */
312 0x0000, /* R24 - System Interrupts */
313 0x0000, /* R25 - Interrupt Status 1 */
314 0x0000, /* R26 - Interrupt Status 2 */
315 0x0000, /* R27 - Power Up Interrupt Status */
316 0x0000, /* R28 - Under Voltage Interrupt status */
317 0x0000, /* R29 - Over Current Interrupt status */
318 0x0000, /* R30 - GPIO Interrupt Status */
319 0x0000, /* R31 - Comparator Interrupt Status */
320 0x3FFF, /* R32 - System Interrupts Mask */
321 0x0000, /* R33 - Interrupt Status 1 Mask */
322 0x0000, /* R34 - Interrupt Status 2 Mask */
323 0x0000, /* R35 - Power Up Interrupt Status Mask */
324 0x0000, /* R36 - Under Voltage Interrupt status Mask */
325 0x0000, /* R37 - Over Current Interrupt status Mask */
326 0x0000, /* R38 - GPIO Interrupt Status Mask */
327 0x0000, /* R39 - Comparator Interrupt Status Mask */
328 0x0040, /* R40 - Clock Control 1 */
329 0x0000, /* R41 - Clock Control 2 */
330 0x3B00, /* R42 - FLL Control 1 */
331 0x7086, /* R43 - FLL Control 2 */
332 0xC226, /* R44 - FLL Control 3 */
333 0x0000, /* R45 - FLL Control 4 */
334 0x0000, /* R46 */
335 0x0000, /* R47 */
336 0x0000, /* R48 - DAC Control */
337 0x0000, /* R49 */
338 0x00C0, /* R50 - DAC Digital Volume L */
339 0x00C0, /* R51 - DAC Digital Volume R */
340 0x0000, /* R52 */
341 0x0040, /* R53 - DAC LR Rate */
342 0x0000, /* R54 - DAC Clock Control */
343 0x0000, /* R55 */
344 0x0000, /* R56 */
345 0x0000, /* R57 */
346 0x4000, /* R58 - DAC Mute */
347 0x0000, /* R59 - DAC Mute Volume */
348 0x0000, /* R60 - DAC Side */
349 0x0000, /* R61 */
350 0x0000, /* R62 */
351 0x0000, /* R63 */
352 0x8000, /* R64 - ADC Control */
353 0x0000, /* R65 */
354 0x00C0, /* R66 - ADC Digital Volume L */
355 0x00C0, /* R67 - ADC Digital Volume R */
356 0x0000, /* R68 - ADC Divider */
357 0x0000, /* R69 */
358 0x0040, /* R70 - ADC LR Rate */
359 0x0000, /* R71 */
360 0x0303, /* R72 - Input Control */
361 0x0000, /* R73 - IN3 Input Control */
362 0x0000, /* R74 - Mic Bias Control */
363 0x0000, /* R75 */
364 0x0000, /* R76 - Output Control */
365 0x0000, /* R77 - Jack Detect */
366 0x0000, /* R78 - Anti Pop Control */
367 0x0000, /* R79 */
368 0x0040, /* R80 - Left Input Volume */
369 0x0040, /* R81 - Right Input Volume */
370 0x0000, /* R82 */
371 0x0000, /* R83 */
372 0x0000, /* R84 */
373 0x0000, /* R85 */
374 0x0000, /* R86 */
375 0x0000, /* R87 */
376 0x0800, /* R88 - Left Mixer Control */
377 0x1000, /* R89 - Right Mixer Control */
378 0x0000, /* R90 */
379 0x0000, /* R91 */
380 0x0000, /* R92 - OUT3 Mixer Control */
381 0x0000, /* R93 - OUT4 Mixer Control */
382 0x0000, /* R94 */
383 0x0000, /* R95 */
384 0x0000, /* R96 - Output Left Mixer Volume */
385 0x0000, /* R97 - Output Right Mixer Volume */
386 0x0000, /* R98 - Input Mixer Volume L */
387 0x0000, /* R99 - Input Mixer Volume R */
388 0x0000, /* R100 - Input Mixer Volume */
389 0x0000, /* R101 */
390 0x0000, /* R102 */
391 0x0000, /* R103 */
392 0x00E4, /* R104 - LOUT1 Volume */
393 0x00E4, /* R105 - ROUT1 Volume */
394 0x00E4, /* R106 - LOUT2 Volume */
395 0x02E4, /* R107 - ROUT2 Volume */
396 0x0000, /* R108 */
397 0x0000, /* R109 */
398 0x0000, /* R110 */
399 0x0000, /* R111 - BEEP Volume */
400 0x0A00, /* R112 - AI Formating */
401 0x0000, /* R113 - ADC DAC COMP */
402 0x0020, /* R114 - AI ADC Control */
403 0x0020, /* R115 - AI DAC Control */
404 0x0000, /* R116 - AIF Test */
405 0x0000, /* R117 */
406 0x0000, /* R118 */
407 0x0000, /* R119 */
408 0x0000, /* R120 */
409 0x0000, /* R121 */
410 0x0000, /* R122 */
411 0x0000, /* R123 */
412 0x0000, /* R124 */
413 0x0000, /* R125 */
414 0x0000, /* R126 */
415 0x0000, /* R127 */
416 0x1FFF, /* R128 - GPIO Debounce */
417 0x0000, /* R129 - GPIO Pin pull up Control */
418 0x03FC, /* R130 - GPIO Pull down Control */
419 0x0000, /* R131 - GPIO Interrupt Mode */
420 0x0000, /* R132 */
421 0x0000, /* R133 - GPIO Control */
422 0x00FB, /* R134 - GPIO Configuration (i/o) */
423 0x04FE, /* R135 - GPIO Pin Polarity / Type */
424 0x0000, /* R136 */
425 0x0000, /* R137 */
426 0x0000, /* R138 */
427 0x0000, /* R139 */
428 0x0312, /* R140 - GPIO Function Select 1 */
429 0x1003, /* R141 - GPIO Function Select 2 */
430 0x1331, /* R142 - GPIO Function Select 3 */
431 0x0003, /* R143 - GPIO Function Select 4 */
432 0x0000, /* R144 - Digitiser Control (1) */
433 0x0002, /* R145 - Digitiser Control (2) */
434 0x0000, /* R146 */
435 0x0000, /* R147 */
436 0x0000, /* R148 */
437 0x0000, /* R149 */
438 0x0000, /* R150 */
439 0x0000, /* R151 */
440 0x7000, /* R152 - AUX1 Readback */
441 0x7000, /* R153 - AUX2 Readback */
442 0x7000, /* R154 - AUX3 Readback */
443 0x7000, /* R155 - AUX4 Readback */
444 0x0000, /* R156 - USB Voltage Readback */
445 0x0000, /* R157 - LINE Voltage Readback */
446 0x0000, /* R158 - BATT Voltage Readback */
447 0x0000, /* R159 - Chip Temp Readback */
448 0x0000, /* R160 */
449 0x0000, /* R161 */
450 0x0000, /* R162 */
451 0x0000, /* R163 - Generic Comparator Control */
452 0x0000, /* R164 - Generic comparator 1 */
453 0x0000, /* R165 - Generic comparator 2 */
454 0x0000, /* R166 - Generic comparator 3 */
455 0x0000, /* R167 - Generic comparator 4 */
456 0xA00F, /* R168 - Battery Charger Control 1 */
457 0x0B06, /* R169 - Battery Charger Control 2 */
458 0x0000, /* R170 - Battery Charger Control 3 */
459 0x0000, /* R171 */
460 0x0000, /* R172 - Current Sink Driver A */
461 0x0000, /* R173 - CSA Flash control */
462 0x0000, /* R174 - Current Sink Driver B */
463 0x0000, /* R175 - CSB Flash control */
464 0x0000, /* R176 - DCDC/LDO requested */
465 0x002D, /* R177 - DCDC Active options */
466 0x0000, /* R178 - DCDC Sleep options */
467 0x0025, /* R179 - Power-check comparator */
468 0x0062, /* R180 - DCDC1 Control */
469 0x0400, /* R181 - DCDC1 Timeouts */
470 0x1006, /* R182 - DCDC1 Low Power */
471 0x0018, /* R183 - DCDC2 Control */
472 0x0000, /* R184 - DCDC2 Timeouts */
473 0x0000, /* R185 */
474 0x0026, /* R186 - DCDC3 Control */
475 0x0400, /* R187 - DCDC3 Timeouts */
476 0x0006, /* R188 - DCDC3 Low Power */
477 0x0062, /* R189 - DCDC4 Control */
478 0x0400, /* R190 - DCDC4 Timeouts */
479 0x0006, /* R191 - DCDC4 Low Power */
480 0x0008, /* R192 - DCDC5 Control */
481 0x0000, /* R193 - DCDC5 Timeouts */
482 0x0000, /* R194 */
483 0x0026, /* R195 - DCDC6 Control */
484 0x0800, /* R196 - DCDC6 Timeouts */
485 0x0006, /* R197 - DCDC6 Low Power */
486 0x0000, /* R198 */
487 0x0003, /* R199 - Limit Switch Control */
488 0x0006, /* R200 - LDO1 Control */
489 0x0400, /* R201 - LDO1 Timeouts */
490 0x001C, /* R202 - LDO1 Low Power */
491 0x0006, /* R203 - LDO2 Control */
492 0x0400, /* R204 - LDO2 Timeouts */
493 0x001C, /* R205 - LDO2 Low Power */
494 0x001B, /* R206 - LDO3 Control */
495 0x0000, /* R207 - LDO3 Timeouts */
496 0x001C, /* R208 - LDO3 Low Power */
497 0x001B, /* R209 - LDO4 Control */
498 0x0000, /* R210 - LDO4 Timeouts */
499 0x001C, /* R211 - LDO4 Low Power */
500 0x0000, /* R212 */
501 0x0000, /* R213 */
502 0x0000, /* R214 */
503 0x0000, /* R215 - VCC_FAULT Masks */
504 0x001F, /* R216 - Main Bandgap Control */
505 0x0000, /* R217 - OSC Control */
506 0x9000, /* R218 - RTC Tick Control */
507 0x0000, /* R219 */
508 0x4000, /* R220 - RAM BIST 1 */
509 0x0000, /* R221 */
510 0x0000, /* R222 */
511 0x0000, /* R223 */
512 0x0000, /* R224 */
513 0x0000, /* R225 - DCDC/LDO status */
514 0x0000, /* R226 */
515 0x0000, /* R227 */
516 0x0000, /* R228 */
517 0x0000, /* R229 */
518 0xE000, /* R230 - GPIO Pin Status */
519 0x0000, /* R231 */
520 0x0000, /* R232 */
521 0x0000, /* R233 */
522 0x0000, /* R234 */
523 0x0000, /* R235 */
524 0x0000, /* R236 */
525 0x0000, /* R237 */
526 0x0000, /* R238 */
527 0x0000, /* R239 */
528 0x0000, /* R240 */
529 0x0000, /* R241 */
530 0x0000, /* R242 */
531 0x0000, /* R243 */
532 0x0000, /* R244 */
533 0x0000, /* R245 */
534 0x0000, /* R246 */
535 0x0000, /* R247 */
536 0x0000, /* R248 */
537 0x0000, /* R249 */
538 0x0000, /* R250 */
539 0x0000, /* R251 */
540 0x0000, /* R252 */
541 0x0000, /* R253 */
542 0x0000, /* R254 */
543 0x0000, /* R255 */
544};
545#endif
546
547#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_2
548
549#undef WM8350_HAVE_CONFIG_MODE
550#define WM8350_HAVE_CONFIG_MODE
551
552const u16 wm8350_mode2_defaults[] = {
553 0x17FF, /* R0 - Reset/ID */
554 0x1000, /* R1 - ID */
555 0x0000, /* R2 */
556 0x1002, /* R3 - System Control 1 */
557 0x0014, /* R4 - System Control 2 */
558 0x0000, /* R5 - System Hibernate */
559 0x8A00, /* R6 - Interface Control */
560 0x0000, /* R7 */
561 0x8000, /* R8 - Power mgmt (1) */
562 0x0000, /* R9 - Power mgmt (2) */
563 0x0000, /* R10 - Power mgmt (3) */
564 0x2000, /* R11 - Power mgmt (4) */
565 0x0E00, /* R12 - Power mgmt (5) */
566 0x0000, /* R13 - Power mgmt (6) */
567 0x0000, /* R14 - Power mgmt (7) */
568 0x0000, /* R15 */
569 0x0000, /* R16 - RTC Seconds/Minutes */
570 0x0100, /* R17 - RTC Hours/Day */
571 0x0101, /* R18 - RTC Date/Month */
572 0x1400, /* R19 - RTC Year */
573 0x0000, /* R20 - Alarm Seconds/Minutes */
574 0x0000, /* R21 - Alarm Hours/Day */
575 0x0000, /* R22 - Alarm Date/Month */
576 0x0320, /* R23 - RTC Time Control */
577 0x0000, /* R24 - System Interrupts */
578 0x0000, /* R25 - Interrupt Status 1 */
579 0x0000, /* R26 - Interrupt Status 2 */
580 0x0000, /* R27 - Power Up Interrupt Status */
581 0x0000, /* R28 - Under Voltage Interrupt status */
582 0x0000, /* R29 - Over Current Interrupt status */
583 0x0000, /* R30 - GPIO Interrupt Status */
584 0x0000, /* R31 - Comparator Interrupt Status */
585 0x3FFF, /* R32 - System Interrupts Mask */
586 0x0000, /* R33 - Interrupt Status 1 Mask */
587 0x0000, /* R34 - Interrupt Status 2 Mask */
588 0x0000, /* R35 - Power Up Interrupt Status Mask */
589 0x0000, /* R36 - Under Voltage Interrupt status Mask */
590 0x0000, /* R37 - Over Current Interrupt status Mask */
591 0x0000, /* R38 - GPIO Interrupt Status Mask */
592 0x0000, /* R39 - Comparator Interrupt Status Mask */
593 0x0040, /* R40 - Clock Control 1 */
594 0x0000, /* R41 - Clock Control 2 */
595 0x3B00, /* R42 - FLL Control 1 */
596 0x7086, /* R43 - FLL Control 2 */
597 0xC226, /* R44 - FLL Control 3 */
598 0x0000, /* R45 - FLL Control 4 */
599 0x0000, /* R46 */
600 0x0000, /* R47 */
601 0x0000, /* R48 - DAC Control */
602 0x0000, /* R49 */
603 0x00C0, /* R50 - DAC Digital Volume L */
604 0x00C0, /* R51 - DAC Digital Volume R */
605 0x0000, /* R52 */
606 0x0040, /* R53 - DAC LR Rate */
607 0x0000, /* R54 - DAC Clock Control */
608 0x0000, /* R55 */
609 0x0000, /* R56 */
610 0x0000, /* R57 */
611 0x4000, /* R58 - DAC Mute */
612 0x0000, /* R59 - DAC Mute Volume */
613 0x0000, /* R60 - DAC Side */
614 0x0000, /* R61 */
615 0x0000, /* R62 */
616 0x0000, /* R63 */
617 0x8000, /* R64 - ADC Control */
618 0x0000, /* R65 */
619 0x00C0, /* R66 - ADC Digital Volume L */
620 0x00C0, /* R67 - ADC Digital Volume R */
621 0x0000, /* R68 - ADC Divider */
622 0x0000, /* R69 */
623 0x0040, /* R70 - ADC LR Rate */
624 0x0000, /* R71 */
625 0x0303, /* R72 - Input Control */
626 0x0000, /* R73 - IN3 Input Control */
627 0x0000, /* R74 - Mic Bias Control */
628 0x0000, /* R75 */
629 0x0000, /* R76 - Output Control */
630 0x0000, /* R77 - Jack Detect */
631 0x0000, /* R78 - Anti Pop Control */
632 0x0000, /* R79 */
633 0x0040, /* R80 - Left Input Volume */
634 0x0040, /* R81 - Right Input Volume */
635 0x0000, /* R82 */
636 0x0000, /* R83 */
637 0x0000, /* R84 */
638 0x0000, /* R85 */
639 0x0000, /* R86 */
640 0x0000, /* R87 */
641 0x0800, /* R88 - Left Mixer Control */
642 0x1000, /* R89 - Right Mixer Control */
643 0x0000, /* R90 */
644 0x0000, /* R91 */
645 0x0000, /* R92 - OUT3 Mixer Control */
646 0x0000, /* R93 - OUT4 Mixer Control */
647 0x0000, /* R94 */
648 0x0000, /* R95 */
649 0x0000, /* R96 - Output Left Mixer Volume */
650 0x0000, /* R97 - Output Right Mixer Volume */
651 0x0000, /* R98 - Input Mixer Volume L */
652 0x0000, /* R99 - Input Mixer Volume R */
653 0x0000, /* R100 - Input Mixer Volume */
654 0x0000, /* R101 */
655 0x0000, /* R102 */
656 0x0000, /* R103 */
657 0x00E4, /* R104 - LOUT1 Volume */
658 0x00E4, /* R105 - ROUT1 Volume */
659 0x00E4, /* R106 - LOUT2 Volume */
660 0x02E4, /* R107 - ROUT2 Volume */
661 0x0000, /* R108 */
662 0x0000, /* R109 */
663 0x0000, /* R110 */
664 0x0000, /* R111 - BEEP Volume */
665 0x0A00, /* R112 - AI Formating */
666 0x0000, /* R113 - ADC DAC COMP */
667 0x0020, /* R114 - AI ADC Control */
668 0x0020, /* R115 - AI DAC Control */
669 0x0000, /* R116 - AIF Test */
670 0x0000, /* R117 */
671 0x0000, /* R118 */
672 0x0000, /* R119 */
673 0x0000, /* R120 */
674 0x0000, /* R121 */
675 0x0000, /* R122 */
676 0x0000, /* R123 */
677 0x0000, /* R124 */
678 0x0000, /* R125 */
679 0x0000, /* R126 */
680 0x0000, /* R127 */
681 0x1FFF, /* R128 - GPIO Debounce */
682 0x0000, /* R129 - GPIO Pin pull up Control */
683 0x03FC, /* R130 - GPIO Pull down Control */
684 0x0000, /* R131 - GPIO Interrupt Mode */
685 0x0000, /* R132 */
686 0x0000, /* R133 - GPIO Control */
687 0x08FB, /* R134 - GPIO Configuration (i/o) */
688 0x0CFE, /* R135 - GPIO Pin Polarity / Type */
689 0x0000, /* R136 */
690 0x0000, /* R137 */
691 0x0000, /* R138 */
692 0x0000, /* R139 */
693 0x0312, /* R140 - GPIO Function Select 1 */
694 0x0003, /* R141 - GPIO Function Select 2 */
695 0x2331, /* R142 - GPIO Function Select 3 */
696 0x0003, /* R143 - GPIO Function Select 4 */
697 0x0000, /* R144 - Digitiser Control (1) */
698 0x0002, /* R145 - Digitiser Control (2) */
699 0x0000, /* R146 */
700 0x0000, /* R147 */
701 0x0000, /* R148 */
702 0x0000, /* R149 */
703 0x0000, /* R150 */
704 0x0000, /* R151 */
705 0x7000, /* R152 - AUX1 Readback */
706 0x7000, /* R153 - AUX2 Readback */
707 0x7000, /* R154 - AUX3 Readback */
708 0x7000, /* R155 - AUX4 Readback */
709 0x0000, /* R156 - USB Voltage Readback */
710 0x0000, /* R157 - LINE Voltage Readback */
711 0x0000, /* R158 - BATT Voltage Readback */
712 0x0000, /* R159 - Chip Temp Readback */
713 0x0000, /* R160 */
714 0x0000, /* R161 */
715 0x0000, /* R162 */
716 0x0000, /* R163 - Generic Comparator Control */
717 0x0000, /* R164 - Generic comparator 1 */
718 0x0000, /* R165 - Generic comparator 2 */
719 0x0000, /* R166 - Generic comparator 3 */
720 0x0000, /* R167 - Generic comparator 4 */
721 0xA00F, /* R168 - Battery Charger Control 1 */
722 0x0B06, /* R169 - Battery Charger Control 2 */
723 0x0000, /* R170 - Battery Charger Control 3 */
724 0x0000, /* R171 */
725 0x0000, /* R172 - Current Sink Driver A */
726 0x0000, /* R173 - CSA Flash control */
727 0x0000, /* R174 - Current Sink Driver B */
728 0x0000, /* R175 - CSB Flash control */
729 0x0000, /* R176 - DCDC/LDO requested */
730 0x002D, /* R177 - DCDC Active options */
731 0x0000, /* R178 - DCDC Sleep options */
732 0x0025, /* R179 - Power-check comparator */
733 0x000E, /* R180 - DCDC1 Control */
734 0x0400, /* R181 - DCDC1 Timeouts */
735 0x1006, /* R182 - DCDC1 Low Power */
736 0x0018, /* R183 - DCDC2 Control */
737 0x0000, /* R184 - DCDC2 Timeouts */
738 0x0000, /* R185 */
739 0x002E, /* R186 - DCDC3 Control */
740 0x0800, /* R187 - DCDC3 Timeouts */
741 0x0006, /* R188 - DCDC3 Low Power */
742 0x000E, /* R189 - DCDC4 Control */
743 0x0800, /* R190 - DCDC4 Timeouts */
744 0x0006, /* R191 - DCDC4 Low Power */
745 0x0008, /* R192 - DCDC5 Control */
746 0x0000, /* R193 - DCDC5 Timeouts */
747 0x0000, /* R194 */
748 0x0026, /* R195 - DCDC6 Control */
749 0x0C00, /* R196 - DCDC6 Timeouts */
750 0x0006, /* R197 - DCDC6 Low Power */
751 0x0000, /* R198 */
752 0x0003, /* R199 - Limit Switch Control */
753 0x001A, /* R200 - LDO1 Control */
754 0x0800, /* R201 - LDO1 Timeouts */
755 0x001C, /* R202 - LDO1 Low Power */
756 0x0010, /* R203 - LDO2 Control */
757 0x0800, /* R204 - LDO2 Timeouts */
758 0x001C, /* R205 - LDO2 Low Power */
759 0x000A, /* R206 - LDO3 Control */
760 0x0C00, /* R207 - LDO3 Timeouts */
761 0x001C, /* R208 - LDO3 Low Power */
762 0x001A, /* R209 - LDO4 Control */
763 0x0800, /* R210 - LDO4 Timeouts */
764 0x001C, /* R211 - LDO4 Low Power */
765 0x0000, /* R212 */
766 0x0000, /* R213 */
767 0x0000, /* R214 */
768 0x0000, /* R215 - VCC_FAULT Masks */
769 0x001F, /* R216 - Main Bandgap Control */
770 0x0000, /* R217 - OSC Control */
771 0x9000, /* R218 - RTC Tick Control */
772 0x0000, /* R219 */
773 0x4000, /* R220 - RAM BIST 1 */
774 0x0000, /* R221 */
775 0x0000, /* R222 */
776 0x0000, /* R223 */
777 0x0000, /* R224 */
778 0x0000, /* R225 - DCDC/LDO status */
779 0x0000, /* R226 */
780 0x0000, /* R227 */
781 0x0000, /* R228 */
782 0x0000, /* R229 */
783 0xE000, /* R230 - GPIO Pin Status */
784 0x0000, /* R231 */
785 0x0000, /* R232 */
786 0x0000, /* R233 */
787 0x0000, /* R234 */
788 0x0000, /* R235 */
789 0x0000, /* R236 */
790 0x0000, /* R237 */
791 0x0000, /* R238 */
792 0x0000, /* R239 */
793 0x0000, /* R240 */
794 0x0000, /* R241 */
795 0x0000, /* R242 */
796 0x0000, /* R243 */
797 0x0000, /* R244 */
798 0x0000, /* R245 */
799 0x0000, /* R246 */
800 0x0000, /* R247 */
801 0x0000, /* R248 */
802 0x0000, /* R249 */
803 0x0000, /* R250 */
804 0x0000, /* R251 */
805 0x0000, /* R252 */
806 0x0000, /* R253 */
807 0x0000, /* R254 */
808 0x0000, /* R255 */
809};
810#endif
811
812#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_3
813
814#undef WM8350_HAVE_CONFIG_MODE
815#define WM8350_HAVE_CONFIG_MODE
816
817const u16 wm8350_mode3_defaults[] = {
818 0x17FF, /* R0 - Reset/ID */
819 0x1000, /* R1 - ID */
820 0x0000, /* R2 */
821 0x1000, /* R3 - System Control 1 */
822 0x0004, /* R4 - System Control 2 */
823 0x0000, /* R5 - System Hibernate */
824 0x8A00, /* R6 - Interface Control */
825 0x0000, /* R7 */
826 0x8000, /* R8 - Power mgmt (1) */
827 0x0000, /* R9 - Power mgmt (2) */
828 0x0000, /* R10 - Power mgmt (3) */
829 0x2000, /* R11 - Power mgmt (4) */
830 0x0E00, /* R12 - Power mgmt (5) */
831 0x0000, /* R13 - Power mgmt (6) */
832 0x0000, /* R14 - Power mgmt (7) */
833 0x0000, /* R15 */
834 0x0000, /* R16 - RTC Seconds/Minutes */
835 0x0100, /* R17 - RTC Hours/Day */
836 0x0101, /* R18 - RTC Date/Month */
837 0x1400, /* R19 - RTC Year */
838 0x0000, /* R20 - Alarm Seconds/Minutes */
839 0x0000, /* R21 - Alarm Hours/Day */
840 0x0000, /* R22 - Alarm Date/Month */
841 0x0320, /* R23 - RTC Time Control */
842 0x0000, /* R24 - System Interrupts */
843 0x0000, /* R25 - Interrupt Status 1 */
844 0x0000, /* R26 - Interrupt Status 2 */
845 0x0000, /* R27 - Power Up Interrupt Status */
846 0x0000, /* R28 - Under Voltage Interrupt status */
847 0x0000, /* R29 - Over Current Interrupt status */
848 0x0000, /* R30 - GPIO Interrupt Status */
849 0x0000, /* R31 - Comparator Interrupt Status */
850 0x3FFF, /* R32 - System Interrupts Mask */
851 0x0000, /* R33 - Interrupt Status 1 Mask */
852 0x0000, /* R34 - Interrupt Status 2 Mask */
853 0x0000, /* R35 - Power Up Interrupt Status Mask */
854 0x0000, /* R36 - Under Voltage Interrupt status Mask */
855 0x0000, /* R37 - Over Current Interrupt status Mask */
856 0x0000, /* R38 - GPIO Interrupt Status Mask */
857 0x0000, /* R39 - Comparator Interrupt Status Mask */
858 0x0040, /* R40 - Clock Control 1 */
859 0x0000, /* R41 - Clock Control 2 */
860 0x3B00, /* R42 - FLL Control 1 */
861 0x7086, /* R43 - FLL Control 2 */
862 0xC226, /* R44 - FLL Control 3 */
863 0x0000, /* R45 - FLL Control 4 */
864 0x0000, /* R46 */
865 0x0000, /* R47 */
866 0x0000, /* R48 - DAC Control */
867 0x0000, /* R49 */
868 0x00C0, /* R50 - DAC Digital Volume L */
869 0x00C0, /* R51 - DAC Digital Volume R */
870 0x0000, /* R52 */
871 0x0040, /* R53 - DAC LR Rate */
872 0x0000, /* R54 - DAC Clock Control */
873 0x0000, /* R55 */
874 0x0000, /* R56 */
875 0x0000, /* R57 */
876 0x4000, /* R58 - DAC Mute */
877 0x0000, /* R59 - DAC Mute Volume */
878 0x0000, /* R60 - DAC Side */
879 0x0000, /* R61 */
880 0x0000, /* R62 */
881 0x0000, /* R63 */
882 0x8000, /* R64 - ADC Control */
883 0x0000, /* R65 */
884 0x00C0, /* R66 - ADC Digital Volume L */
885 0x00C0, /* R67 - ADC Digital Volume R */
886 0x0000, /* R68 - ADC Divider */
887 0x0000, /* R69 */
888 0x0040, /* R70 - ADC LR Rate */
889 0x0000, /* R71 */
890 0x0303, /* R72 - Input Control */
891 0x0000, /* R73 - IN3 Input Control */
892 0x0000, /* R74 - Mic Bias Control */
893 0x0000, /* R75 */
894 0x0000, /* R76 - Output Control */
895 0x0000, /* R77 - Jack Detect */
896 0x0000, /* R78 - Anti Pop Control */
897 0x0000, /* R79 */
898 0x0040, /* R80 - Left Input Volume */
899 0x0040, /* R81 - Right Input Volume */
900 0x0000, /* R82 */
901 0x0000, /* R83 */
902 0x0000, /* R84 */
903 0x0000, /* R85 */
904 0x0000, /* R86 */
905 0x0000, /* R87 */
906 0x0800, /* R88 - Left Mixer Control */
907 0x1000, /* R89 - Right Mixer Control */
908 0x0000, /* R90 */
909 0x0000, /* R91 */
910 0x0000, /* R92 - OUT3 Mixer Control */
911 0x0000, /* R93 - OUT4 Mixer Control */
912 0x0000, /* R94 */
913 0x0000, /* R95 */
914 0x0000, /* R96 - Output Left Mixer Volume */
915 0x0000, /* R97 - Output Right Mixer Volume */
916 0x0000, /* R98 - Input Mixer Volume L */
917 0x0000, /* R99 - Input Mixer Volume R */
918 0x0000, /* R100 - Input Mixer Volume */
919 0x0000, /* R101 */
920 0x0000, /* R102 */
921 0x0000, /* R103 */
922 0x00E4, /* R104 - LOUT1 Volume */
923 0x00E4, /* R105 - ROUT1 Volume */
924 0x00E4, /* R106 - LOUT2 Volume */
925 0x02E4, /* R107 - ROUT2 Volume */
926 0x0000, /* R108 */
927 0x0000, /* R109 */
928 0x0000, /* R110 */
929 0x0000, /* R111 - BEEP Volume */
930 0x0A00, /* R112 - AI Formating */
931 0x0000, /* R113 - ADC DAC COMP */
932 0x0020, /* R114 - AI ADC Control */
933 0x0020, /* R115 - AI DAC Control */
934 0x0000, /* R116 - AIF Test */
935 0x0000, /* R117 */
936 0x0000, /* R118 */
937 0x0000, /* R119 */
938 0x0000, /* R120 */
939 0x0000, /* R121 */
940 0x0000, /* R122 */
941 0x0000, /* R123 */
942 0x0000, /* R124 */
943 0x0000, /* R125 */
944 0x0000, /* R126 */
945 0x0000, /* R127 */
946 0x1FFF, /* R128 - GPIO Debounce */
947 0x0000, /* R129 - GPIO Pin pull up Control */
948 0x03FC, /* R130 - GPIO Pull down Control */
949 0x0000, /* R131 - GPIO Interrupt Mode */
950 0x0000, /* R132 */
951 0x0000, /* R133 - GPIO Control */
952 0x0A7B, /* R134 - GPIO Configuration (i/o) */
953 0x06FE, /* R135 - GPIO Pin Polarity / Type */
954 0x0000, /* R136 */
955 0x0000, /* R137 */
956 0x0000, /* R138 */
957 0x0000, /* R139 */
958 0x1312, /* R140 - GPIO Function Select 1 */
959 0x1030, /* R141 - GPIO Function Select 2 */
960 0x2231, /* R142 - GPIO Function Select 3 */
961 0x0003, /* R143 - GPIO Function Select 4 */
962 0x0000, /* R144 - Digitiser Control (1) */
963 0x0002, /* R145 - Digitiser Control (2) */
964 0x0000, /* R146 */
965 0x0000, /* R147 */
966 0x0000, /* R148 */
967 0x0000, /* R149 */
968 0x0000, /* R150 */
969 0x0000, /* R151 */
970 0x7000, /* R152 - AUX1 Readback */
971 0x7000, /* R153 - AUX2 Readback */
972 0x7000, /* R154 - AUX3 Readback */
973 0x7000, /* R155 - AUX4 Readback */
974 0x0000, /* R156 - USB Voltage Readback */
975 0x0000, /* R157 - LINE Voltage Readback */
976 0x0000, /* R158 - BATT Voltage Readback */
977 0x0000, /* R159 - Chip Temp Readback */
978 0x0000, /* R160 */
979 0x0000, /* R161 */
980 0x0000, /* R162 */
981 0x0000, /* R163 - Generic Comparator Control */
982 0x0000, /* R164 - Generic comparator 1 */
983 0x0000, /* R165 - Generic comparator 2 */
984 0x0000, /* R166 - Generic comparator 3 */
985 0x0000, /* R167 - Generic comparator 4 */
986 0xA00F, /* R168 - Battery Charger Control 1 */
987 0x0B06, /* R169 - Battery Charger Control 2 */
988 0x0000, /* R170 - Battery Charger Control 3 */
989 0x0000, /* R171 */
990 0x0000, /* R172 - Current Sink Driver A */
991 0x0000, /* R173 - CSA Flash control */
992 0x0000, /* R174 - Current Sink Driver B */
993 0x0000, /* R175 - CSB Flash control */
994 0x0000, /* R176 - DCDC/LDO requested */
995 0x002D, /* R177 - DCDC Active options */
996 0x0000, /* R178 - DCDC Sleep options */
997 0x0025, /* R179 - Power-check comparator */
998 0x000E, /* R180 - DCDC1 Control */
999 0x0400, /* R181 - DCDC1 Timeouts */
1000 0x1006, /* R182 - DCDC1 Low Power */
1001 0x0018, /* R183 - DCDC2 Control */
1002 0x0000, /* R184 - DCDC2 Timeouts */
1003 0x0000, /* R185 */
1004 0x000E, /* R186 - DCDC3 Control */
1005 0x0400, /* R187 - DCDC3 Timeouts */
1006 0x0006, /* R188 - DCDC3 Low Power */
1007 0x0026, /* R189 - DCDC4 Control */
1008 0x0400, /* R190 - DCDC4 Timeouts */
1009 0x0006, /* R191 - DCDC4 Low Power */
1010 0x0008, /* R192 - DCDC5 Control */
1011 0x0000, /* R193 - DCDC5 Timeouts */
1012 0x0000, /* R194 */
1013 0x0026, /* R195 - DCDC6 Control */
1014 0x0400, /* R196 - DCDC6 Timeouts */
1015 0x0006, /* R197 - DCDC6 Low Power */
1016 0x0000, /* R198 */
1017 0x0003, /* R199 - Limit Switch Control */
1018 0x001C, /* R200 - LDO1 Control */
1019 0x0000, /* R201 - LDO1 Timeouts */
1020 0x001C, /* R202 - LDO1 Low Power */
1021 0x001C, /* R203 - LDO2 Control */
1022 0x0400, /* R204 - LDO2 Timeouts */
1023 0x001C, /* R205 - LDO2 Low Power */
1024 0x001C, /* R206 - LDO3 Control */
1025 0x0400, /* R207 - LDO3 Timeouts */
1026 0x001C, /* R208 - LDO3 Low Power */
1027 0x001F, /* R209 - LDO4 Control */
1028 0x0400, /* R210 - LDO4 Timeouts */
1029 0x001C, /* R211 - LDO4 Low Power */
1030 0x0000, /* R212 */
1031 0x0000, /* R213 */
1032 0x0000, /* R214 */
1033 0x0000, /* R215 - VCC_FAULT Masks */
1034 0x001F, /* R216 - Main Bandgap Control */
1035 0x0000, /* R217 - OSC Control */
1036 0x9000, /* R218 - RTC Tick Control */
1037 0x0000, /* R219 */
1038 0x4000, /* R220 - RAM BIST 1 */
1039 0x0000, /* R221 */
1040 0x0000, /* R222 */
1041 0x0000, /* R223 */
1042 0x0000, /* R224 */
1043 0x0000, /* R225 - DCDC/LDO status */
1044 0x0000, /* R226 */
1045 0x0000, /* R227 */
1046 0x0000, /* R228 */
1047 0x0000, /* R229 */
1048 0xE000, /* R230 - GPIO Pin Status */
1049 0x0000, /* R231 */
1050 0x0000, /* R232 */
1051 0x0000, /* R233 */
1052 0x0000, /* R234 */
1053 0x0000, /* R235 */
1054 0x0000, /* R236 */
1055 0x0000, /* R237 */
1056 0x0000, /* R238 */
1057 0x0000, /* R239 */
1058 0x0000, /* R240 */
1059 0x0000, /* R241 */
1060 0x0000, /* R242 */
1061 0x0000, /* R243 */
1062 0x0000, /* R244 */
1063 0x0000, /* R245 */
1064 0x0000, /* R246 */
1065 0x0000, /* R247 */
1066 0x0000, /* R248 */
1067 0x0000, /* R249 */
1068 0x0000, /* R250 */
1069 0x0000, /* R251 */
1070 0x0000, /* R252 */
1071 0x0000, /* R253 */
1072 0x0000, /* R254 */
1073 0x0000, /* R255 */
1074};
1075#endif
1076
1077/* The register defaults for the config mode used must be compiled in but
1078 * due to the impact on kernel size it is possible to disable
1079 */
1080#ifndef WM8350_HAVE_CONFIG_MODE
1081#warning No WM8350 config modes supported - select at least one of the
1082#warning MFD_WM8350_CONFIG_MODE_n options from the board driver.
1083#endif
1084
1085/*
1086 * Access masks.
1087 */
1088
1089const struct wm8350_reg_access wm8350_reg_io_map[] = {
1090 /* read write volatile */
1091 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R0 - Reset/ID */
1092 { 0x7CFF, 0x0C00, 0x7FFF }, /* R1 - ID */
1093 { 0x0000, 0x0000, 0x0000 }, /* R2 */
1094 { 0xBE3B, 0xBE3B, 0x8000 }, /* R3 - System Control 1 */
1095 { 0xFCF7, 0xFCF7, 0xF800 }, /* R4 - System Control 2 */
1096 { 0x80FF, 0x80FF, 0x8000 }, /* R5 - System Hibernate */
1097 { 0xFB0E, 0xFB0E, 0x0000 }, /* R6 - Interface Control */
1098 { 0x0000, 0x0000, 0x0000 }, /* R7 */
1099 { 0xE537, 0xE537, 0xFFFF }, /* R8 - Power mgmt (1) */
1100 { 0x0FF3, 0x0FF3, 0xFFFF }, /* R9 - Power mgmt (2) */
1101 { 0x008F, 0x008F, 0xFFFF }, /* R10 - Power mgmt (3) */
1102 { 0x6D3C, 0x6D3C, 0xFFFF }, /* R11 - Power mgmt (4) */
1103 { 0x1F8F, 0x1F8F, 0xFFFF }, /* R12 - Power mgmt (5) */
1104 { 0x8F3F, 0x8F3F, 0xFFFF }, /* R13 - Power mgmt (6) */
1105 { 0x0003, 0x0003, 0xFFFF }, /* R14 - Power mgmt (7) */
1106 { 0x0000, 0x0000, 0x0000 }, /* R15 */
1107 { 0x7F7F, 0x7F7F, 0xFFFF }, /* R16 - RTC Seconds/Minutes */
1108 { 0x073F, 0x073F, 0xFFFF }, /* R17 - RTC Hours/Day */
1109 { 0x1F3F, 0x1F3F, 0xFFFF }, /* R18 - RTC Date/Month */
1110 { 0x3FFF, 0x00FF, 0xFFFF }, /* R19 - RTC Year */
1111 { 0x7F7F, 0x7F7F, 0x0000 }, /* R20 - Alarm Seconds/Minutes */
1112 { 0x0F3F, 0x0F3F, 0x0000 }, /* R21 - Alarm Hours/Day */
1113 { 0x1F3F, 0x1F3F, 0x0000 }, /* R22 - Alarm Date/Month */
1114 { 0xEF7F, 0xEA7F, 0xFFFF }, /* R23 - RTC Time Control */
1115 { 0x3BFF, 0x0000, 0xFFFF }, /* R24 - System Interrupts */
1116 { 0xFEE7, 0x0000, 0xFFFF }, /* R25 - Interrupt Status 1 */
1117 { 0x35FF, 0x0000, 0xFFFF }, /* R26 - Interrupt Status 2 */
1118 { 0x0F3F, 0x0000, 0xFFFF }, /* R27 - Power Up Interrupt Status */
1119 { 0x0F3F, 0x0000, 0xFFFF }, /* R28 - Under Voltage Interrupt status */
1120 { 0x8000, 0x0000, 0xFFFF }, /* R29 - Over Current Interrupt status */
1121 { 0x1FFF, 0x0000, 0xFFFF }, /* R30 - GPIO Interrupt Status */
1122 { 0xEF7F, 0x0000, 0xFFFF }, /* R31 - Comparator Interrupt Status */
1123 { 0x3FFF, 0x3FFF, 0x0000 }, /* R32 - System Interrupts Mask */
1124 { 0xFEE7, 0xFEE7, 0x0000 }, /* R33 - Interrupt Status 1 Mask */
1125 { 0xF5FF, 0xF5FF, 0x0000 }, /* R34 - Interrupt Status 2 Mask */
1126 { 0x0F3F, 0x0F3F, 0x0000 }, /* R35 - Power Up Interrupt Status Mask */
1127 { 0x0F3F, 0x0F3F, 0x0000 }, /* R36 - Under Voltage Int status Mask */
1128 { 0x8000, 0x8000, 0x0000 }, /* R37 - Over Current Int status Mask */
1129 { 0x1FFF, 0x1FFF, 0x0000 }, /* R38 - GPIO Interrupt Status Mask */
1130 { 0xEF7F, 0xEF7F, 0x0000 }, /* R39 - Comparator IntStatus Mask */
1131 { 0xC9F7, 0xC9F7, 0xFFFF }, /* R40 - Clock Control 1 */
1132 { 0x8001, 0x8001, 0x0000 }, /* R41 - Clock Control 2 */
1133 { 0xFFF7, 0xFFF7, 0xFFFF }, /* R42 - FLL Control 1 */
1134 { 0xFBFF, 0xFBFF, 0x0000 }, /* R43 - FLL Control 2 */
1135 { 0xFFFF, 0xFFFF, 0x0000 }, /* R44 - FLL Control 3 */
1136 { 0x0033, 0x0033, 0x0000 }, /* R45 - FLL Control 4 */
1137 { 0x0000, 0x0000, 0x0000 }, /* R46 */
1138 { 0x0000, 0x0000, 0x0000 }, /* R47 */
1139 { 0x3033, 0x3033, 0x0000 }, /* R48 - DAC Control */
1140 { 0x0000, 0x0000, 0x0000 }, /* R49 */
1141 { 0x81FF, 0x81FF, 0xFFFF }, /* R50 - DAC Digital Volume L */
1142 { 0x81FF, 0x81FF, 0xFFFF }, /* R51 - DAC Digital Volume R */
1143 { 0x0000, 0x0000, 0x0000 }, /* R52 */
1144 { 0x0FFF, 0x0FFF, 0xFFFF }, /* R53 - DAC LR Rate */
1145 { 0x0017, 0x0017, 0x0000 }, /* R54 - DAC Clock Control */
1146 { 0x0000, 0x0000, 0x0000 }, /* R55 */
1147 { 0x0000, 0x0000, 0x0000 }, /* R56 */
1148 { 0x0000, 0x0000, 0x0000 }, /* R57 */
1149 { 0x4000, 0x4000, 0x0000 }, /* R58 - DAC Mute */
1150 { 0x7000, 0x7000, 0x0000 }, /* R59 - DAC Mute Volume */
1151 { 0x3C00, 0x3C00, 0x0000 }, /* R60 - DAC Side */
1152 { 0x0000, 0x0000, 0x0000 }, /* R61 */
1153 { 0x0000, 0x0000, 0x0000 }, /* R62 */
1154 { 0x0000, 0x0000, 0x0000 }, /* R63 */
1155 { 0x8303, 0x8303, 0xFFFF }, /* R64 - ADC Control */
1156 { 0x0000, 0x0000, 0x0000 }, /* R65 */
1157 { 0x81FF, 0x81FF, 0xFFFF }, /* R66 - ADC Digital Volume L */
1158 { 0x81FF, 0x81FF, 0xFFFF }, /* R67 - ADC Digital Volume R */
1159 { 0x0FFF, 0x0FFF, 0x0000 }, /* R68 - ADC Divider */
1160 { 0x0000, 0x0000, 0x0000 }, /* R69 */
1161 { 0x0FFF, 0x0FFF, 0xFFFF }, /* R70 - ADC LR Rate */
1162 { 0x0000, 0x0000, 0x0000 }, /* R71 */
1163 { 0x0707, 0x0707, 0xFFFF }, /* R72 - Input Control */
1164 { 0xC0C0, 0xC0C0, 0xFFFF }, /* R73 - IN3 Input Control */
1165 { 0xC09F, 0xC09F, 0xFFFF }, /* R74 - Mic Bias Control */
1166 { 0x0000, 0x0000, 0x0000 }, /* R75 */
1167 { 0x0F15, 0x0F15, 0xFFFF }, /* R76 - Output Control */
1168 { 0xC000, 0xC000, 0xFFFF }, /* R77 - Jack Detect */
1169 { 0x03FF, 0x03FF, 0x0000 }, /* R78 - Anti Pop Control */
1170 { 0x0000, 0x0000, 0x0000 }, /* R79 */
1171 { 0xE1FC, 0xE1FC, 0x8000 }, /* R80 - Left Input Volume */
1172 { 0xE1FC, 0xE1FC, 0x8000 }, /* R81 - Right Input Volume */
1173 { 0x0000, 0x0000, 0x0000 }, /* R82 */
1174 { 0x0000, 0x0000, 0x0000 }, /* R83 */
1175 { 0x0000, 0x0000, 0x0000 }, /* R84 */
1176 { 0x0000, 0x0000, 0x0000 }, /* R85 */
1177 { 0x0000, 0x0000, 0x0000 }, /* R86 */
1178 { 0x0000, 0x0000, 0x0000 }, /* R87 */
1179 { 0x9807, 0x9807, 0xFFFF }, /* R88 - Left Mixer Control */
1180 { 0x980B, 0x980B, 0xFFFF }, /* R89 - Right Mixer Control */
1181 { 0x0000, 0x0000, 0x0000 }, /* R90 */
1182 { 0x0000, 0x0000, 0x0000 }, /* R91 */
1183 { 0x8909, 0x8909, 0xFFFF }, /* R92 - OUT3 Mixer Control */
1184 { 0x9E07, 0x9E07, 0xFFFF }, /* R93 - OUT4 Mixer Control */
1185 { 0x0000, 0x0000, 0x0000 }, /* R94 */
1186 { 0x0000, 0x0000, 0x0000 }, /* R95 */
1187 { 0x0EEE, 0x0EEE, 0x0000 }, /* R96 - Output Left Mixer Volume */
1188 { 0xE0EE, 0xE0EE, 0x0000 }, /* R97 - Output Right Mixer Volume */
1189 { 0x0E0F, 0x0E0F, 0x0000 }, /* R98 - Input Mixer Volume L */
1190 { 0xE0E1, 0xE0E1, 0x0000 }, /* R99 - Input Mixer Volume R */
1191 { 0x800E, 0x800E, 0x0000 }, /* R100 - Input Mixer Volume */
1192 { 0x0000, 0x0000, 0x0000 }, /* R101 */
1193 { 0x0000, 0x0000, 0x0000 }, /* R102 */
1194 { 0x0000, 0x0000, 0x0000 }, /* R103 */
1195 { 0xE1FC, 0xE1FC, 0xFFFF }, /* R104 - LOUT1 Volume */
1196 { 0xE1FC, 0xE1FC, 0xFFFF }, /* R105 - ROUT1 Volume */
1197 { 0xE1FC, 0xE1FC, 0xFFFF }, /* R106 - LOUT2 Volume */
1198 { 0xE7FC, 0xE7FC, 0xFFFF }, /* R107 - ROUT2 Volume */
1199 { 0x0000, 0x0000, 0x0000 }, /* R108 */
1200 { 0x0000, 0x0000, 0x0000 }, /* R109 */
1201 { 0x0000, 0x0000, 0x0000 }, /* R110 */
1202 { 0x80E0, 0x80E0, 0xFFFF }, /* R111 - BEEP Volume */
1203 { 0xBF00, 0xBF00, 0x0000 }, /* R112 - AI Formating */
1204 { 0x00F1, 0x00F1, 0x0000 }, /* R113 - ADC DAC COMP */
1205 { 0x00F8, 0x00F8, 0x0000 }, /* R114 - AI ADC Control */
1206 { 0x40FB, 0x40FB, 0x0000 }, /* R115 - AI DAC Control */
1207 { 0x7C30, 0x7C30, 0x0000 }, /* R116 - AIF Test */
1208 { 0x0000, 0x0000, 0x0000 }, /* R117 */
1209 { 0x0000, 0x0000, 0x0000 }, /* R118 */
1210 { 0x0000, 0x0000, 0x0000 }, /* R119 */
1211 { 0x0000, 0x0000, 0x0000 }, /* R120 */
1212 { 0x0000, 0x0000, 0x0000 }, /* R121 */
1213 { 0x0000, 0x0000, 0x0000 }, /* R122 */
1214 { 0x0000, 0x0000, 0x0000 }, /* R123 */
1215 { 0x0000, 0x0000, 0x0000 }, /* R124 */
1216 { 0x0000, 0x0000, 0x0000 }, /* R125 */
1217 { 0x0000, 0x0000, 0x0000 }, /* R126 */
1218 { 0x0000, 0x0000, 0x0000 }, /* R127 */
1219 { 0x1FFF, 0x1FFF, 0x0000 }, /* R128 - GPIO Debounce */
1220 { 0x1FFF, 0x1FFF, 0x0000 }, /* R129 - GPIO Pin pull up Control */
1221 { 0x1FFF, 0x1FFF, 0x0000 }, /* R130 - GPIO Pull down Control */
1222 { 0x1FFF, 0x1FFF, 0x0000 }, /* R131 - GPIO Interrupt Mode */
1223 { 0x0000, 0x0000, 0x0000 }, /* R132 */
1224 { 0x00C0, 0x00C0, 0x0000 }, /* R133 - GPIO Control */
1225 { 0x1FFF, 0x1FFF, 0x0000 }, /* R134 - GPIO Configuration (i/o) */
1226 { 0x1FFF, 0x1FFF, 0x0000 }, /* R135 - GPIO Pin Polarity / Type */
1227 { 0x0000, 0x0000, 0x0000 }, /* R136 */
1228 { 0x0000, 0x0000, 0x0000 }, /* R137 */
1229 { 0x0000, 0x0000, 0x0000 }, /* R138 */
1230 { 0x0000, 0x0000, 0x0000 }, /* R139 */
1231 { 0xFFFF, 0xFFFF, 0x0000 }, /* R140 - GPIO Function Select 1 */
1232 { 0xFFFF, 0xFFFF, 0x0000 }, /* R141 - GPIO Function Select 2 */
1233 { 0xFFFF, 0xFFFF, 0x0000 }, /* R142 - GPIO Function Select 3 */
1234 { 0x000F, 0x000F, 0x0000 }, /* R143 - GPIO Function Select 4 */
1235 { 0xF0FF, 0xF0FF, 0xA000 }, /* R144 - Digitiser Control (1) */
1236 { 0x3707, 0x3707, 0x0000 }, /* R145 - Digitiser Control (2) */
1237 { 0x0000, 0x0000, 0x0000 }, /* R146 */
1238 { 0x0000, 0x0000, 0x0000 }, /* R147 */
1239 { 0x0000, 0x0000, 0x0000 }, /* R148 */
1240 { 0x0000, 0x0000, 0x0000 }, /* R149 */
1241 { 0x0000, 0x0000, 0x0000 }, /* R150 */
1242 { 0x0000, 0x0000, 0x0000 }, /* R151 */
1243 { 0x7FFF, 0x7000, 0xFFFF }, /* R152 - AUX1 Readback */
1244 { 0x7FFF, 0x7000, 0xFFFF }, /* R153 - AUX2 Readback */
1245 { 0x7FFF, 0x7000, 0xFFFF }, /* R154 - AUX3 Readback */
1246 { 0x7FFF, 0x7000, 0xFFFF }, /* R155 - AUX4 Readback */
1247 { 0x0FFF, 0x0000, 0xFFFF }, /* R156 - USB Voltage Readback */
1248 { 0x0FFF, 0x0000, 0xFFFF }, /* R157 - LINE Voltage Readback */
1249 { 0x0FFF, 0x0000, 0xFFFF }, /* R158 - BATT Voltage Readback */
1250 { 0x0FFF, 0x0000, 0xFFFF }, /* R159 - Chip Temp Readback */
1251 { 0x0000, 0x0000, 0x0000 }, /* R160 */
1252 { 0x0000, 0x0000, 0x0000 }, /* R161 */
1253 { 0x0000, 0x0000, 0x0000 }, /* R162 */
1254 { 0x000F, 0x000F, 0x0000 }, /* R163 - Generic Comparator Control */
1255 { 0xFFFF, 0xFFFF, 0x0000 }, /* R164 - Generic comparator 1 */
1256 { 0xFFFF, 0xFFFF, 0x0000 }, /* R165 - Generic comparator 2 */
1257 { 0xFFFF, 0xFFFF, 0x0000 }, /* R166 - Generic comparator 3 */
1258 { 0xFFFF, 0xFFFF, 0x0000 }, /* R167 - Generic comparator 4 */
1259 { 0xBFFF, 0xBFFF, 0x8000 }, /* R168 - Battery Charger Control 1 */
1260 { 0xFFFF, 0x4FFF, 0xB000 }, /* R169 - Battery Charger Control 2 */
1261 { 0x007F, 0x007F, 0x0000 }, /* R170 - Battery Charger Control 3 */
1262 { 0x0000, 0x0000, 0x0000 }, /* R171 */
1263 { 0x903F, 0x903F, 0xFFFF }, /* R172 - Current Sink Driver A */
1264 { 0xE333, 0xE333, 0xFFFF }, /* R173 - CSA Flash control */
1265 { 0x903F, 0x903F, 0xFFFF }, /* R174 - Current Sink Driver B */
1266 { 0xE333, 0xE333, 0xFFFF }, /* R175 - CSB Flash control */
1267 { 0x8F3F, 0x8F3F, 0xFFFF }, /* R176 - DCDC/LDO requested */
1268 { 0x332D, 0x332D, 0x0000 }, /* R177 - DCDC Active options */
1269 { 0x002D, 0x002D, 0x0000 }, /* R178 - DCDC Sleep options */
1270 { 0x5177, 0x5177, 0x8000 }, /* R179 - Power-check comparator */
1271 { 0x047F, 0x047F, 0x0000 }, /* R180 - DCDC1 Control */
1272 { 0xFFC0, 0xFFC0, 0x0000 }, /* R181 - DCDC1 Timeouts */
1273 { 0x737F, 0x737F, 0x0000 }, /* R182 - DCDC1 Low Power */
1274 { 0x535B, 0x535B, 0x0000 }, /* R183 - DCDC2 Control */
1275 { 0xFFC0, 0xFFC0, 0x0000 }, /* R184 - DCDC2 Timeouts */
1276 { 0x0000, 0x0000, 0x0000 }, /* R185 */
1277 { 0x047F, 0x047F, 0x0000 }, /* R186 - DCDC3 Control */
1278 { 0xFFC0, 0xFFC0, 0x0000 }, /* R187 - DCDC3 Timeouts */
1279 { 0x737F, 0x737F, 0x0000 }, /* R188 - DCDC3 Low Power */
1280 { 0x047F, 0x047F, 0x0000 }, /* R189 - DCDC4 Control */
1281 { 0xFFC0, 0xFFC0, 0x0000 }, /* R190 - DCDC4 Timeouts */
1282 { 0x737F, 0x737F, 0x0000 }, /* R191 - DCDC4 Low Power */
1283 { 0x535B, 0x535B, 0x0000 }, /* R192 - DCDC5 Control */
1284 { 0xFFC0, 0xFFC0, 0x0000 }, /* R193 - DCDC5 Timeouts */
1285 { 0x0000, 0x0000, 0x0000 }, /* R194 */
1286 { 0x047F, 0x047F, 0x0000 }, /* R195 - DCDC6 Control */
1287 { 0xFFC0, 0xFFC0, 0x0000 }, /* R196 - DCDC6 Timeouts */
1288 { 0x737F, 0x737F, 0x0000 }, /* R197 - DCDC6 Low Power */
1289 { 0x0000, 0x0000, 0x0000 }, /* R198 */
1290 { 0xFFD3, 0xFFD3, 0x0000 }, /* R199 - Limit Switch Control */
1291 { 0x441F, 0x441F, 0x0000 }, /* R200 - LDO1 Control */
1292 { 0xFFC0, 0xFFC0, 0x0000 }, /* R201 - LDO1 Timeouts */
1293 { 0x331F, 0x331F, 0x0000 }, /* R202 - LDO1 Low Power */
1294 { 0x441F, 0x441F, 0x0000 }, /* R203 - LDO2 Control */
1295 { 0xFFC0, 0xFFC0, 0x0000 }, /* R204 - LDO2 Timeouts */
1296 { 0x331F, 0x331F, 0x0000 }, /* R205 - LDO2 Low Power */
1297 { 0x441F, 0x441F, 0x0000 }, /* R206 - LDO3 Control */
1298 { 0xFFC0, 0xFFC0, 0x0000 }, /* R207 - LDO3 Timeouts */
1299 { 0x331F, 0x331F, 0x0000 }, /* R208 - LDO3 Low Power */
1300 { 0x441F, 0x441F, 0x0000 }, /* R209 - LDO4 Control */
1301 { 0xFFC0, 0xFFC0, 0x0000 }, /* R210 - LDO4 Timeouts */
1302 { 0x331F, 0x331F, 0x0000 }, /* R211 - LDO4 Low Power */
1303 { 0x0000, 0x0000, 0x0000 }, /* R212 */
1304 { 0x0000, 0x0000, 0x0000 }, /* R213 */
1305 { 0x0000, 0x0000, 0x0000 }, /* R214 */
1306 { 0x8F3F, 0x8F3F, 0x0000 }, /* R215 - VCC_FAULT Masks */
1307 { 0xFF3F, 0xE03F, 0x0000 }, /* R216 - Main Bandgap Control */
1308 { 0xEF2F, 0xE02F, 0x0000 }, /* R217 - OSC Control */
1309 { 0xF3FF, 0xB3FF, 0xc000 }, /* R218 - RTC Tick Control */
1310 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R219 */
1311 { 0x09FF, 0x01FF, 0x0000 }, /* R220 - RAM BIST 1 */
1312 { 0x0000, 0x0000, 0x0000 }, /* R221 */
1313 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R222 */
1314 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R223 */
1315 { 0x0000, 0x0000, 0x0000 }, /* R224 */
1316 { 0x8F3F, 0x0000, 0xFFFF }, /* R225 - DCDC/LDO status */
1317 { 0x0000, 0x0000, 0x0000 }, /* R226 */
1318 { 0x0000, 0x0000, 0xFFFF }, /* R227 */
1319 { 0x0000, 0x0000, 0x0000 }, /* R228 */
1320 { 0x0000, 0x0000, 0x0000 }, /* R229 */
1321 { 0xFFFF, 0x1FFF, 0xFFFF }, /* R230 - GPIO Pin Status */
1322 { 0xFFFF, 0x1FFF, 0xFFFF }, /* R231 */
1323 { 0xFFFF, 0x1FFF, 0xFFFF }, /* R232 */
1324 { 0xFFFF, 0x1FFF, 0xFFFF }, /* R233 */
1325 { 0x0000, 0x0000, 0x0000 }, /* R234 */
1326 { 0x0000, 0x0000, 0x0000 }, /* R235 */
1327 { 0x0000, 0x0000, 0x0000 }, /* R236 */
1328 { 0x0000, 0x0000, 0x0000 }, /* R237 */
1329 { 0x0000, 0x0000, 0x0000 }, /* R238 */
1330 { 0x0000, 0x0000, 0x0000 }, /* R239 */
1331 { 0x0000, 0x0000, 0x0000 }, /* R240 */
1332 { 0x0000, 0x0000, 0x0000 }, /* R241 */
1333 { 0x0000, 0x0000, 0x0000 }, /* R242 */
1334 { 0x0000, 0x0000, 0x0000 }, /* R243 */
1335 { 0x0000, 0x0000, 0x0000 }, /* R244 */
1336 { 0x0000, 0x0000, 0x0000 }, /* R245 */
1337 { 0x0000, 0x0000, 0x0000 }, /* R246 */
1338 { 0x0000, 0x0000, 0x0000 }, /* R247 */
1339 { 0xFFFF, 0x0010, 0xFFFF }, /* R248 */
1340 { 0x0000, 0x0000, 0x0000 }, /* R249 */
1341 { 0xFFFF, 0x0010, 0xFFFF }, /* R250 */
1342 { 0xFFFF, 0x0010, 0xFFFF }, /* R251 */
1343 { 0x0000, 0x0000, 0x0000 }, /* R252 */
1344 { 0xFFFF, 0x0010, 0xFFFF }, /* R253 */
1345 { 0x0000, 0x0000, 0x0000 }, /* R254 */
1346 { 0x0000, 0x0000, 0x0000 }, /* R255 */
1347};
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
new file mode 100644
index 000000000000..6a0cedb5bb8a
--- /dev/null
+++ b/drivers/mfd/wm8400-core.c
@@ -0,0 +1,455 @@
1/*
2 * Core driver for WM8400.
3 *
4 * Copyright 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 */
14
15#include <linux/bug.h>
16#include <linux/i2c.h>
17#include <linux/kernel.h>
18#include <linux/mfd/wm8400-private.h>
19#include <linux/mfd/wm8400-audio.h>
20
21static struct {
22 u16 readable; /* Mask of readable bits */
23 u16 writable; /* Mask of writable bits */
24 u16 vol; /* Mask of volatile bits */
25 int is_codec; /* Register controlled by codec reset */
26 u16 default_val; /* Value on reset */
27} reg_data[] = {
28 { 0xFFFF, 0xFFFF, 0x0000, 0, 0x6172 }, /* R0 */
29 { 0x7000, 0x0000, 0x8000, 0, 0x0000 }, /* R1 */
30 { 0xFF17, 0xFF17, 0x0000, 0, 0x0000 }, /* R2 */
31 { 0xEBF3, 0xEBF3, 0x0000, 1, 0x6000 }, /* R3 */
32 { 0x3CF3, 0x3CF3, 0x0000, 1, 0x0000 }, /* R4 */
33 { 0xF1F8, 0xF1F8, 0x0000, 1, 0x4050 }, /* R5 */
34 { 0xFC1F, 0xFC1F, 0x0000, 1, 0x4000 }, /* R6 */
35 { 0xDFDE, 0xDFDE, 0x0000, 1, 0x01C8 }, /* R7 */
36 { 0xFCFC, 0xFCFC, 0x0000, 1, 0x0000 }, /* R8 */
37 { 0xEFFF, 0xEFFF, 0x0000, 1, 0x0040 }, /* R9 */
38 { 0xEFFF, 0xEFFF, 0x0000, 1, 0x0040 }, /* R10 */
39 { 0x27F7, 0x27F7, 0x0000, 1, 0x0004 }, /* R11 */
40 { 0x01FF, 0x01FF, 0x0000, 1, 0x00C0 }, /* R12 */
41 { 0x01FF, 0x01FF, 0x0000, 1, 0x00C0 }, /* R13 */
42 { 0x1FEF, 0x1FEF, 0x0000, 1, 0x0000 }, /* R14 */
43 { 0x0163, 0x0163, 0x0000, 1, 0x0100 }, /* R15 */
44 { 0x01FF, 0x01FF, 0x0000, 1, 0x00C0 }, /* R16 */
45 { 0x01FF, 0x01FF, 0x0000, 1, 0x00C0 }, /* R17 */
46 { 0x1FFF, 0x0FFF, 0x0000, 1, 0x0000 }, /* R18 */
47 { 0xFFFF, 0xFFFF, 0x0000, 1, 0x1000 }, /* R19 */
48 { 0xFFFF, 0xFFFF, 0x0000, 1, 0x1010 }, /* R20 */
49 { 0xFFFF, 0xFFFF, 0x0000, 1, 0x1010 }, /* R21 */
50 { 0x0FDD, 0x0FDD, 0x0000, 1, 0x8000 }, /* R22 */
51 { 0x1FFF, 0x1FFF, 0x0000, 1, 0x0800 }, /* R23 */
52 { 0x0000, 0x01DF, 0x0000, 1, 0x008B }, /* R24 */
53 { 0x0000, 0x01DF, 0x0000, 1, 0x008B }, /* R25 */
54 { 0x0000, 0x01DF, 0x0000, 1, 0x008B }, /* R26 */
55 { 0x0000, 0x01DF, 0x0000, 1, 0x008B }, /* R27 */
56 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R28 */
57 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R29 */
58 { 0x0000, 0x0077, 0x0000, 1, 0x0066 }, /* R30 */
59 { 0x0000, 0x0033, 0x0000, 1, 0x0022 }, /* R31 */
60 { 0x0000, 0x01FF, 0x0000, 1, 0x0079 }, /* R32 */
61 { 0x0000, 0x01FF, 0x0000, 1, 0x0079 }, /* R33 */
62 { 0x0000, 0x0003, 0x0000, 1, 0x0003 }, /* R34 */
63 { 0x0000, 0x01FF, 0x0000, 1, 0x0003 }, /* R35 */
64 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R36 */
65 { 0x0000, 0x003F, 0x0000, 1, 0x0100 }, /* R37 */
66 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R38 */
67 { 0x0000, 0x000F, 0x0000, 0, 0x0000 }, /* R39 */
68 { 0x0000, 0x00FF, 0x0000, 1, 0x0000 }, /* R40 */
69 { 0x0000, 0x01B7, 0x0000, 1, 0x0000 }, /* R41 */
70 { 0x0000, 0x01B7, 0x0000, 1, 0x0000 }, /* R42 */
71 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R43 */
72 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R44 */
73 { 0x0000, 0x00FD, 0x0000, 1, 0x0000 }, /* R45 */
74 { 0x0000, 0x00FD, 0x0000, 1, 0x0000 }, /* R46 */
75 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R47 */
76 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R48 */
77 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R49 */
78 { 0x0000, 0x01FF, 0x0000, 1, 0x0000 }, /* R50 */
79 { 0x0000, 0x01B3, 0x0000, 1, 0x0180 }, /* R51 */
80 { 0x0000, 0x0077, 0x0000, 1, 0x0000 }, /* R52 */
81 { 0x0000, 0x0077, 0x0000, 1, 0x0000 }, /* R53 */
82 { 0x0000, 0x00FF, 0x0000, 1, 0x0000 }, /* R54 */
83 { 0x0000, 0x0001, 0x0000, 1, 0x0000 }, /* R55 */
84 { 0x0000, 0x003F, 0x0000, 1, 0x0000 }, /* R56 */
85 { 0x0000, 0x004F, 0x0000, 1, 0x0000 }, /* R57 */
86 { 0x0000, 0x00FD, 0x0000, 1, 0x0000 }, /* R58 */
87 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R59 */
88 { 0x1FFF, 0x1FFF, 0x0000, 1, 0x0000 }, /* R60 */
89 { 0xFFFF, 0xFFFF, 0x0000, 1, 0x0000 }, /* R61 */
90 { 0x03FF, 0x03FF, 0x0000, 1, 0x0000 }, /* R62 */
91 { 0x007F, 0x007F, 0x0000, 1, 0x0000 }, /* R63 */
92 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R64 */
93 { 0xDFFF, 0xDFFF, 0x0000, 0, 0x0000 }, /* R65 */
94 { 0xDFFF, 0xDFFF, 0x0000, 0, 0x0000 }, /* R66 */
95 { 0xDFFF, 0xDFFF, 0x0000, 0, 0x0000 }, /* R67 */
96 { 0xDFFF, 0xDFFF, 0x0000, 0, 0x0000 }, /* R68 */
97 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R69 */
98 { 0xFFFF, 0xFFFF, 0x0000, 0, 0x4400 }, /* R70 */
99 { 0x23FF, 0x23FF, 0x0000, 0, 0x0000 }, /* R71 */
100 { 0xFFFF, 0xFFFF, 0x0000, 0, 0x4400 }, /* R72 */
101 { 0x23FF, 0x23FF, 0x0000, 0, 0x0000 }, /* R73 */
102 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R74 */
103 { 0x000E, 0x000E, 0x0000, 0, 0x0008 }, /* R75 */
104 { 0xE00F, 0xE00F, 0x0000, 0, 0x0000 }, /* R76 */
105 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R77 */
106 { 0x03C0, 0x03C0, 0x0000, 0, 0x02C0 }, /* R78 */
107 { 0xFFFF, 0x0000, 0xffff, 0, 0x0000 }, /* R79 */
108 { 0xFFFF, 0xFFFF, 0x0000, 0, 0x0000 }, /* R80 */
109 { 0xFFFF, 0x0000, 0xffff, 0, 0x0000 }, /* R81 */
110 { 0x2BFF, 0x0000, 0xffff, 0, 0x0000 }, /* R82 */
111 { 0x0000, 0x0000, 0x0000, 0, 0x0000 }, /* R83 */
112 { 0x80FF, 0x80FF, 0x0000, 0, 0x00ff }, /* R84 */
113};
114
115static int wm8400_read(struct wm8400 *wm8400, u8 reg, int num_regs, u16 *dest)
116{
117 int i, ret = 0;
118
119 BUG_ON(reg + num_regs - 1 > ARRAY_SIZE(wm8400->reg_cache));
120
121 /* If there are any volatile reads then read back the entire block */
122 for (i = reg; i < reg + num_regs; i++)
123 if (reg_data[i].vol) {
124 ret = wm8400->read_dev(wm8400->io_data, reg,
125 num_regs, dest);
126 if (ret != 0)
127 return ret;
128 for (i = 0; i < num_regs; i++)
129 dest[i] = be16_to_cpu(dest[i]);
130
131 return 0;
132 }
133
134 /* Otherwise use the cache */
135 memcpy(dest, &wm8400->reg_cache[reg], num_regs * sizeof(u16));
136
137 return 0;
138}
139
140static int wm8400_write(struct wm8400 *wm8400, u8 reg, int num_regs,
141 u16 *src)
142{
143 int ret, i;
144
145 BUG_ON(reg + num_regs - 1 > ARRAY_SIZE(wm8400->reg_cache));
146
147 for (i = 0; i < num_regs; i++) {
148 BUG_ON(!reg_data[reg + i].writable);
149 wm8400->reg_cache[reg + i] = src[i];
150 src[i] = cpu_to_be16(src[i]);
151 }
152
153 /* Do the actual I/O */
154 ret = wm8400->write_dev(wm8400->io_data, reg, num_regs, src);
155 if (ret != 0)
156 return -EIO;
157
158 return 0;
159}
160
161/**
162 * wm8400_reg_read - Single register read
163 *
164 * @wm8400: Pointer to wm8400 control structure
165 * @reg: Register to read
166 *
167 * @return Read value
168 */
169u16 wm8400_reg_read(struct wm8400 *wm8400, u8 reg)
170{
171 u16 val;
172
173 mutex_lock(&wm8400->io_lock);
174
175 wm8400_read(wm8400, reg, 1, &val);
176
177 mutex_unlock(&wm8400->io_lock);
178
179 return val;
180}
181EXPORT_SYMBOL_GPL(wm8400_reg_read);
182
183int wm8400_block_read(struct wm8400 *wm8400, u8 reg, int count, u16 *data)
184{
185 int ret;
186
187 mutex_lock(&wm8400->io_lock);
188
189 ret = wm8400_read(wm8400, reg, count, data);
190
191 mutex_unlock(&wm8400->io_lock);
192
193 return ret;
194}
195EXPORT_SYMBOL_GPL(wm8400_block_read);
196
197/**
198 * wm8400_set_bits - Bitmask write
199 *
200 * @wm8400: Pointer to wm8400 control structure
201 * @reg: Register to access
202 * @mask: Mask of bits to change
203 * @val: Value to set for masked bits
204 */
205int wm8400_set_bits(struct wm8400 *wm8400, u8 reg, u16 mask, u16 val)
206{
207 u16 tmp;
208 int ret;
209
210 mutex_lock(&wm8400->io_lock);
211
212 ret = wm8400_read(wm8400, reg, 1, &tmp);
213 tmp = (tmp & ~mask) | val;
214 if (ret == 0)
215 ret = wm8400_write(wm8400, reg, 1, &tmp);
216
217 mutex_unlock(&wm8400->io_lock);
218
219 return ret;
220}
221EXPORT_SYMBOL_GPL(wm8400_set_bits);
222
223/**
224 * wm8400_reset_codec_reg_cache - Reset cached codec registers to
225 * their default values.
226 */
227void wm8400_reset_codec_reg_cache(struct wm8400 *wm8400)
228{
229 int i;
230
231 mutex_lock(&wm8400->io_lock);
232
233 /* Reset all codec registers to their initial value */
234 for (i = 0; i < ARRAY_SIZE(wm8400->reg_cache); i++)
235 if (reg_data[i].is_codec)
236 wm8400->reg_cache[i] = reg_data[i].default_val;
237
238 mutex_unlock(&wm8400->io_lock);
239}
240EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache);
241
242/*
243 * wm8400_init - Generic initialisation
244 *
245 * The WM8400 can be configured as either an I2C or SPI device. Probe
246 * functions for each bus set up the accessors then call into this to
247 * set up the device itself.
248 */
249static int wm8400_init(struct wm8400 *wm8400,
250 struct wm8400_platform_data *pdata)
251{
252 u16 reg;
253 int ret, i;
254
255 mutex_init(&wm8400->io_lock);
256
257 wm8400->dev->driver_data = wm8400;
258
259 /* Check that this is actually a WM8400 */
260 ret = wm8400->read_dev(wm8400->io_data, WM8400_RESET_ID, 1, &reg);
261 if (ret != 0) {
262 dev_err(wm8400->dev, "Chip ID register read failed\n");
263 return -EIO;
264 }
265 if (be16_to_cpu(reg) != reg_data[WM8400_RESET_ID].default_val) {
266 dev_err(wm8400->dev, "Device is not a WM8400, ID is %x\n",
267 be16_to_cpu(reg));
268 return -ENODEV;
269 }
270
271 /* We don't know what state the hardware is in and since this
272 * is a PMIC we can't reset it safely so initialise the register
273 * cache from the hardware.
274 */
275 ret = wm8400->read_dev(wm8400->io_data, 0,
276 ARRAY_SIZE(wm8400->reg_cache),
277 wm8400->reg_cache);
278 if (ret != 0) {
279 dev_err(wm8400->dev, "Register cache read failed\n");
280 return -EIO;
281 }
282 for (i = 0; i < ARRAY_SIZE(wm8400->reg_cache); i++)
283 wm8400->reg_cache[i] = be16_to_cpu(wm8400->reg_cache[i]);
284
285 /* If the codec is in reset use hard coded values */
286 if (!(wm8400->reg_cache[WM8400_POWER_MANAGEMENT_1] & WM8400_CODEC_ENA))
287 for (i = 0; i < ARRAY_SIZE(wm8400->reg_cache); i++)
288 if (reg_data[i].is_codec)
289 wm8400->reg_cache[i] = reg_data[i].default_val;
290
291 ret = wm8400_read(wm8400, WM8400_ID, 1, &reg);
292 if (ret != 0) {
293 dev_err(wm8400->dev, "ID register read failed: %d\n", ret);
294 return ret;
295 }
296 reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT;
297 dev_info(wm8400->dev, "WM8400 revision %x\n", reg);
298
299 if (pdata && pdata->platform_init) {
300 ret = pdata->platform_init(wm8400->dev);
301 if (ret != 0)
302 dev_err(wm8400->dev, "Platform init failed: %d\n",
303 ret);
304 } else
305 dev_warn(wm8400->dev, "No platform initialisation supplied\n");
306
307 return ret;
308}
309
310static void wm8400_release(struct wm8400 *wm8400)
311{
312 int i;
313
314 for (i = 0; i < ARRAY_SIZE(wm8400->regulators); i++)
315 if (wm8400->regulators[i].name)
316 platform_device_unregister(&wm8400->regulators[i]);
317}
318
319#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
320static int wm8400_i2c_read(void *io_data, char reg, int count, u16 *dest)
321{
322 struct i2c_client *i2c = io_data;
323 struct i2c_msg xfer[2];
324 int ret;
325
326 /* Write register */
327 xfer[0].addr = i2c->addr;
328 xfer[0].flags = 0;
329 xfer[0].len = 1;
330 xfer[0].buf = &reg;
331
332 /* Read data */
333 xfer[1].addr = i2c->addr;
334 xfer[1].flags = I2C_M_RD;
335 xfer[1].len = count * sizeof(u16);
336 xfer[1].buf = (u8 *)dest;
337
338 ret = i2c_transfer(i2c->adapter, xfer, 2);
339 if (ret == 2)
340 ret = 0;
341 else if (ret >= 0)
342 ret = -EIO;
343
344 return ret;
345}
346
347static int wm8400_i2c_write(void *io_data, char reg, int count, const u16 *src)
348{
349 struct i2c_client *i2c = io_data;
350 u8 *msg;
351 int ret;
352
353 /* We add 1 byte for device register - ideally I2C would gather. */
354 msg = kmalloc((count * sizeof(u16)) + 1, GFP_KERNEL);
355 if (msg == NULL)
356 return -ENOMEM;
357
358 msg[0] = reg;
359 memcpy(&msg[1], src, count * sizeof(u16));
360
361 ret = i2c_master_send(i2c, msg, (count * sizeof(u16)) + 1);
362
363 if (ret == (count * 2) + 1)
364 ret = 0;
365 else if (ret >= 0)
366 ret = -EIO;
367
368 kfree(msg);
369
370 return ret;
371}
372
373static int wm8400_i2c_probe(struct i2c_client *i2c,
374 const struct i2c_device_id *id)
375{
376 struct wm8400 *wm8400;
377 int ret;
378
379 wm8400 = kzalloc(sizeof(struct wm8400), GFP_KERNEL);
380 if (wm8400 == NULL) {
381 ret = -ENOMEM;
382 goto err;
383 }
384
385 wm8400->io_data = i2c;
386 wm8400->read_dev = wm8400_i2c_read;
387 wm8400->write_dev = wm8400_i2c_write;
388 wm8400->dev = &i2c->dev;
389 i2c_set_clientdata(i2c, wm8400);
390
391 ret = wm8400_init(wm8400, i2c->dev.platform_data);
392 if (ret != 0)
393 goto struct_err;
394
395 return 0;
396
397struct_err:
398 i2c_set_clientdata(i2c, NULL);
399 kfree(wm8400);
400err:
401 return ret;
402}
403
404static int wm8400_i2c_remove(struct i2c_client *i2c)
405{
406 struct wm8400 *wm8400 = i2c_get_clientdata(i2c);
407
408 wm8400_release(wm8400);
409 i2c_set_clientdata(i2c, NULL);
410 kfree(wm8400);
411
412 return 0;
413}
414
415static const struct i2c_device_id wm8400_i2c_id[] = {
416 { "wm8400", 0 },
417 { }
418};
419MODULE_DEVICE_TABLE(i2c, wm8400_i2c_id);
420
421static struct i2c_driver wm8400_i2c_driver = {
422 .driver = {
423 .name = "WM8400",
424 .owner = THIS_MODULE,
425 },
426 .probe = wm8400_i2c_probe,
427 .remove = wm8400_i2c_remove,
428 .id_table = wm8400_i2c_id,
429};
430#endif
431
432static int __init wm8400_module_init(void)
433{
434 int ret = -ENODEV;
435
436#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
437 ret = i2c_add_driver(&wm8400_i2c_driver);
438 if (ret != 0)
439 pr_err("Failed to register I2C driver: %d\n", ret);
440#endif
441
442 return ret;
443}
444module_init(wm8400_module_init);
445
446static void __exit wm8400_module_exit(void)
447{
448#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
449 i2c_del_driver(&wm8400_i2c_driver);
450#endif
451}
452module_exit(wm8400_module_exit);
453
454MODULE_LICENSE("GPL");
455MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c
index 5ba4bab6d43e..7d15e7c6bcad 100644
--- a/drivers/net/3c501.c
+++ b/drivers/net/3c501.c
@@ -17,7 +17,7 @@
17 Annapolis MD 21403 17 Annapolis MD 21403
18 18
19 Fixed (again!) the missing interrupt locking on TX/RX shifting. 19 Fixed (again!) the missing interrupt locking on TX/RX shifting.
20 Alan Cox <Alan.Cox@linux.org> 20 Alan Cox <alan@lxorguk.ukuu.org.uk>
21 21
22 Removed calls to init_etherdev since they are no longer needed, and 22 Removed calls to init_etherdev since they are no longer needed, and
23 cleaned up modularization just a bit. The driver still allows only 23 cleaned up modularization just a bit. The driver still allows only
@@ -29,16 +29,16 @@
29 the board. Now getting 150K/second FTP with a 3c501 card. Still playing 29 the board. Now getting 150K/second FTP with a 3c501 card. Still playing
30 with a TX-TX optimisation to see if we can touch 180-200K/second as seems 30 with a TX-TX optimisation to see if we can touch 180-200K/second as seems
31 theoretically maximum. 31 theoretically maximum.
32 19950402 Alan Cox <Alan.Cox@linux.org> 32 19950402 Alan Cox <alan@lxorguk.ukuu.org.uk>
33 33
34 Cleaned up for 2.3.x because we broke SMP now. 34 Cleaned up for 2.3.x because we broke SMP now.
35 20000208 Alan Cox <alan@redhat.com> 35 20000208 Alan Cox <alan@lxorguk.ukuu.org.uk>
36 36
37 Check up pass for 2.5. Nothing significant changed 37 Check up pass for 2.5. Nothing significant changed
38 20021009 Alan Cox <alan@redhat.com> 38 20021009 Alan Cox <alan@lxorguk.ukuu.org.uk>
39 39
40 Fixed zero fill corner case 40 Fixed zero fill corner case
41 20030104 Alan Cox <alan@redhat.com> 41 20030104 Alan Cox <alan@lxorguk.ukuu.org.uk>
42 42
43 43
44 For the avoidance of doubt the "preferred form" of this code is one which 44 For the avoidance of doubt the "preferred form" of this code is one which
@@ -104,7 +104,7 @@
104 104
105 105
106static const char version[] = 106static const char version[] =
107 DRV_NAME ".c: " DRV_VERSION " Alan Cox (alan@redhat.com).\n"; 107 DRV_NAME ".c: " DRV_VERSION " Alan Cox (alan@lxorguk.ukuu.org.uk).\n";
108 108
109/* 109/*
110 * Braindamage remaining: 110 * Braindamage remaining:
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index e4e3241628d6..a0f8b6e2d0af 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -18,7 +18,7 @@
18 18
19 2001/11/17 - Added ethtool support (jgarzik) 19 2001/11/17 - Added ethtool support (jgarzik)
20 20
21 2002/10/28 - Locking updates for 2.5 (alan@redhat.com) 21 2002/10/28 - Locking updates for 2.5 (alan@lxorguk.ukuu.org.uk)
22 22
23*/ 23*/
24 24
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e9d529442b06..1d8af3348331 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2400,7 +2400,7 @@ config EHEA
2400 will be called ehea. 2400 will be called ehea.
2401 2401
2402config ENIC 2402config ENIC
2403 tristate "E, the Cisco 10G Ethernet NIC" 2403 tristate "Cisco 10G Ethernet NIC support"
2404 depends on PCI && INET 2404 depends on PCI && INET
2405 select INET_LRO 2405 select INET_LRO
2406 help 2406 help
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index a0b4c8516073..735fc9476403 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -4,7 +4,7 @@
4 * - Jay Schulist <jschlst@samba.org> 4 * - Jay Schulist <jschlst@samba.org>
5 * 5 *
6 * With more than a little help from; 6 * With more than a little help from;
7 * - Alan Cox <Alan.Cox@linux.org> 7 * - Alan Cox <alan@lxorguk.ukuu.org.uk>
8 * 8 *
9 * Derived from: 9 * Derived from:
10 * - skeleton.c: A network driver outline for linux. 10 * - skeleton.c: A network driver outline for linux.
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 455ef529cd62..bc8e2413abd2 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c
index 744fac0b1617..5c3c05da4d96 100644
--- a/drivers/net/cxgb3/ael1002.c
+++ b/drivers/net/cxgb3/ael1002.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 593fb643a615..e312d315a42d 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/cxgb3_ctl_defs.h b/drivers/net/cxgb3/cxgb3_ctl_defs.h
index 6ad92405d9a0..1d8d46eb3c96 100644
--- a/drivers/net/cxgb3/cxgb3_ctl_defs.h
+++ b/drivers/net/cxgb3/cxgb3_ctl_defs.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/cxgb3_defs.h b/drivers/net/cxgb3/cxgb3_defs.h
index 45e92164c260..47e53769af5b 100644
--- a/drivers/net/cxgb3/cxgb3_defs.h
+++ b/drivers/net/cxgb3/cxgb3_defs.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2006-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/cxgb3_ioctl.h b/drivers/net/cxgb3/cxgb3_ioctl.h
index 3e8d5faec3a4..b19e4376ba76 100644
--- a/drivers/net/cxgb3/cxgb3_ioctl.h
+++ b/drivers/net/cxgb3/cxgb3_ioctl.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index f31985df0bb9..1ace41a13ac3 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index 0f6fd63b2847..265aa8a15afa 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2006-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/cxgb3_offload.h b/drivers/net/cxgb3/cxgb3_offload.h
index 7a379138b5a6..d514e5019dfc 100644
--- a/drivers/net/cxgb3/cxgb3_offload.h
+++ b/drivers/net/cxgb3/cxgb3_offload.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2006-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/firmware_exports.h b/drivers/net/cxgb3/firmware_exports.h
index b75ddd8777fe..0d9b0e6dccff 100644
--- a/drivers/net/cxgb3/firmware_exports.h
+++ b/drivers/net/cxgb3/firmware_exports.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2004-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2004-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
index b2c5314582aa..4407ac9bb555 100644
--- a/drivers/net/cxgb3/l2t.c
+++ b/drivers/net/cxgb3/l2t.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/l2t.h b/drivers/net/cxgb3/l2t.h
index 42ce65f76a87..fd3eb07e3f40 100644
--- a/drivers/net/cxgb3/l2t.h
+++ b/drivers/net/cxgb3/l2t.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/mc5.c b/drivers/net/cxgb3/mc5.c
index 4c4d6e877ea6..3b5517b8fbde 100644
--- a/drivers/net/cxgb3/mc5.c
+++ b/drivers/net/cxgb3/mc5.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 87919419b707..c6480be0bc1f 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/t3_cpl.h b/drivers/net/cxgb3/t3_cpl.h
index 917970ed24a1..852c399a8b0a 100644
--- a/drivers/net/cxgb3/t3_cpl.h
+++ b/drivers/net/cxgb3/t3_cpl.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2004-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2004-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index 4da5b09b9bc2..968f64be3743 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/t3cdev.h b/drivers/net/cxgb3/t3cdev.h
index 0a21cfbd2b21..be55e9ae74d1 100644
--- a/drivers/net/cxgb3/t3cdev.h
+++ b/drivers/net/cxgb3/t3cdev.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2006-2007 Chelsio Communications. All rights reserved. 2 * Copyright (C) 2006-2008 Chelsio Communications. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/version.h b/drivers/net/cxgb3/version.h
index 29db711303b9..bb8698a86754 100644
--- a/drivers/net/cxgb3/version.h
+++ b/drivers/net/cxgb3/version.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -35,7 +35,7 @@
35#define DRV_DESC "Chelsio T3 Network Driver" 35#define DRV_DESC "Chelsio T3 Network Driver"
36#define DRV_NAME "cxgb3" 36#define DRV_NAME "cxgb3"
37/* Driver version */ 37/* Driver version */
38#define DRV_VERSION "1.0-ko" 38#define DRV_VERSION "1.1.0-ko"
39 39
40/* Firmware version */ 40/* Firmware version */
41#define FW_VERSION_MAJOR 7 41#define FW_VERSION_MAJOR 7
diff --git a/drivers/net/cxgb3/vsc8211.c b/drivers/net/cxgb3/vsc8211.c
index 306c2dc4ab34..33f956bd6b59 100644
--- a/drivers/net/cxgb3/vsc8211.c
+++ b/drivers/net/cxgb3/vsc8211.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/cxgb3/xgmac.c b/drivers/net/cxgb3/xgmac.c
index ffdc0a1892bd..9d7786937aad 100644
--- a/drivers/net/cxgb3/xgmac.c
+++ b/drivers/net/cxgb3/xgmac.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2007 Chelsio, Inc. All rights reserved. 2 * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index 795c594a4b7c..b751c1b96cfa 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * Many modifications, and currently maintained, by 9 * Many modifications, and currently maintained, by
10 * Philip Blundell <philb@gnu.org> 10 * Philip Blundell <philb@gnu.org>
11 * Added the Compaq LTE Alan Cox <alan@redhat.com> 11 * Added the Compaq LTE Alan Cox <alan@lxorguk.ukuu.org.uk>
12 * Added MCA support Adam Fritzler 12 * Added MCA support Adam Fritzler
13 * 13 *
14 * Note - this driver is experimental still - it has problems on faster 14 * Note - this driver is experimental still - it has problems on faster
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index f3a47a87dbbe..180e968dc54d 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -34,6 +34,7 @@
34#include <linux/ip.h> 34#include <linux/ip.h>
35#include <linux/ipv6.h> 35#include <linux/ipv6.h>
36#include <linux/tcp.h> 36#include <linux/tcp.h>
37#include <net/ip6_checksum.h>
37 38
38#include "cq_enet_desc.h" 39#include "cq_enet_desc.h"
39#include "vnic_dev.h" 40#include "vnic_dev.h"
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index 95e3464068db..f02764725a22 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -71,7 +71,7 @@ History:
71 June 1st, 2000 71 June 1st, 2000
72 corrected version codes, added support for the latest 2.3 changes 72 corrected version codes, added support for the latest 2.3 changes
73 Oct 28th, 2002 73 Oct 28th, 2002
74 cleaned up for the 2.5 tree <alan@redhat.com> 74 cleaned up for the 2.5 tree <alan@lxorguk.ukuu.org.uk>
75 75
76 *************************************************************************/ 76 *************************************************************************/
77 77
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 156f159aafbb..81c6cdc3851f 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -37,6 +37,7 @@
37#include <linux/tcp.h> 37#include <linux/tcp.h>
38#include <linux/udp.h> 38#include <linux/udp.h>
39#include <linux/if_vlan.h> 39#include <linux/if_vlan.h>
40#include <net/ip6_checksum.h>
40#include "jme.h" 41#include "jme.h"
41 42
42static int force_pseudohp = -1; 43static int force_pseudohp = -1;
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 51ad3765e075..85587a6667b9 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -9,7 +9,7 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 * 10 *
11 * Copyright (C) 1996 Paul Mackerras. 11 * Copyright (C) 1996 Paul Mackerras.
12 * Copyright (C) 1998 Alan Cox <alan@redhat.com> 12 * Copyright (C) 1998 Alan Cox <alan@lxorguk.ukuu.org.uk>
13 * 13 *
14 * Modified heavily by Joshua M. Thompson based on Dave Huang's NetBSD driver 14 * Modified heavily by Joshua M. Thompson based on Dave Huang's NetBSD driver
15 * 15 *
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 0b28d0d8ffa8..c235cdba69c6 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -15,7 +15,7 @@
15 incorporated herein by reference. 15 incorporated herein by reference.
16 Donald Becker may be reached at becker@scyld.com 16 Donald Becker may be reached at becker@scyld.com
17 17
18 Updated for 2.5.x by Alan Cox <alan@redhat.com> 18 Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk>
19 19
20======================================================================*/ 20======================================================================*/
21 21
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 54df34f21c5f..448cd40aeba5 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -69,7 +69,7 @@ Driver Notes and Issues
69History 69History
70------------------------------------------------------------------------------- 70-------------------------------------------------------------------------------
71Log: nmclan_cs.c,v 71Log: nmclan_cs.c,v
72 * 2.5.75-ac1 2003/07/11 Alan Cox <alan@redhat.com> 72 * 2.5.75-ac1 2003/07/11 Alan Cox <alan@lxorguk.ukuu.org.uk>
73 * Fixed hang on card eject as we probe it 73 * Fixed hang on card eject as we probe it
74 * Cleaned up to use new style locking. 74 * Cleaned up to use new style locking.
75 * 75 *
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6671e2da0d57..d0ed1ef284a8 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -55,6 +55,7 @@ EXPORT_SYMBOL(mdiobus_alloc);
55 55
56/** 56/**
57 * mdiobus_release - mii_bus device release callback 57 * mdiobus_release - mii_bus device release callback
58 * @d: the target struct device that contains the mii_bus
58 * 59 *
59 * Description: called when the last reference to an mii_bus is 60 * Description: called when the last reference to an mii_bus is
60 * dropped, to free the underlying memory. 61 * dropped, to free the underlying memory.
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 171627480058..f11e900b437b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -557,6 +557,7 @@ int genphy_restart_aneg(struct phy_device *phydev)
557 557
558 return ctl; 558 return ctl;
559} 559}
560EXPORT_SYMBOL(genphy_restart_aneg);
560 561
561 562
562/** 563/**
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index c37ea436c918..38116f9d4163 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -58,7 +58,7 @@
58 */ 58 */
59#if (PAGE_SHIFT == 12) || (PAGE_SHIFT == 13) /* 4k & 8k pages */ 59#if (PAGE_SHIFT == 12) || (PAGE_SHIFT == 13) /* 4k & 8k pages */
60#define TX_DESC_PER_OAL ((MAX_SKB_FRAGS - TX_DESC_PER_IOCB) + 2) 60#define TX_DESC_PER_OAL ((MAX_SKB_FRAGS - TX_DESC_PER_IOCB) + 2)
61#elif (PAGE_SHIFT == 16) /* 64k pages */ 61#else /* all other page sizes */
62#define TX_DESC_PER_OAL 0 62#define TX_DESC_PER_OAL 0
63#endif 63#endif
64 64
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 297877b68c46..4b2caa6b7ac5 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -39,6 +39,7 @@
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/mm.h> 40#include <linux/mm.h>
41#include <linux/vmalloc.h> 41#include <linux/vmalloc.h>
42#include <net/ip6_checksum.h>
42 43
43#include "qlge.h" 44#include "qlge.h"
44 45
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index ec871f646766..c41d68761364 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -29,7 +29,8 @@
29 * 29 *
30 * Tigran Aivazian <tigran@sco.com>: TLan_PciProbe() now uses 30 * Tigran Aivazian <tigran@sco.com>: TLan_PciProbe() now uses
31 * new PCI BIOS interface. 31 * new PCI BIOS interface.
32 * Alan Cox <alan@redhat.com>: Fixed the out of memory 32 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
33 * Fixed the out of memory
33 * handling. 34 * handling.
34 * 35 *
35 * Torben Mathiasen <torben.mathiasen@compaq.com> New Maintainer! 36 * Torben Mathiasen <torben.mathiasen@compaq.com> New Maintainer!
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index fa73e6eed6be..ed50d288e494 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -25,7 +25,7 @@
25 * To do: 25 * To do:
26 * 1. Multicast support. 26 * 1. Multicast support.
27 * 27 *
28 * Initial 2.5 cleanup Alan Cox <alan@redhat.com> 2002/10/28 28 * Initial 2.5 cleanup Alan Cox <alan@lxorguk.ukuu.org.uk> 2002/10/28
29 */ 29 */
30 30
31#include <linux/module.h> 31#include <linux/module.h>
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index f54c45049d50..124d5d690dde 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1688,6 +1688,7 @@ static void __devinit de21040_get_mac_address (struct de_private *de)
1688 unsigned i; 1688 unsigned i;
1689 1689
1690 dw32 (ROMCmd, 0); /* Reset the pointer with a dummy write. */ 1690 dw32 (ROMCmd, 0); /* Reset the pointer with a dummy write. */
1691 udelay(5);
1691 1692
1692 for (i = 0; i < 6; i++) { 1693 for (i = 0; i < 6; i++) {
1693 int value, boguscnt = 100000; 1694 int value, boguscnt = 100000;
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 656200472fa1..8e46a513a252 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -23,7 +23,7 @@
23 Marcelo Tosatti <marcelo@conectiva.com.br> : 23 Marcelo Tosatti <marcelo@conectiva.com.br> :
24 Made it compile in 2.3 (device to net_device) 24 Made it compile in 2.3 (device to net_device)
25 25
26 Alan Cox <alan@redhat.com> : 26 Alan Cox <alan@lxorguk.ukuu.org.uk> :
27 Cleaned up for kernel merge. 27 Cleaned up for kernel merge.
28 Removed the back compatibility support 28 Removed the back compatibility support
29 Reformatted, fixing spelling etc as I went 29 Reformatted, fixing spelling etc as I went
@@ -49,7 +49,7 @@
49 support. Updated PCI resource allocation. Do not 49 support. Updated PCI resource allocation. Do not
50 forget to unmap PCI mapped skbs. 50 forget to unmap PCI mapped skbs.
51 51
52 Alan Cox <alan@redhat.com> 52 Alan Cox <alan@lxorguk.ukuu.org.uk>
53 Added new PCI identifiers provided by Clear Zhang at ALi 53 Added new PCI identifiers provided by Clear Zhang at ALi
54 for their 1563 ethernet device. 54 for their 1563 ethernet device.
55 55
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index ad20f96edfa1..2dced383bcfb 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -12,7 +12,7 @@
12 * Scatter gather 12 * Scatter gather
13 * More testing 13 * More testing
14 * 14 *
15 * The changes are (c) Copyright 2004, Red Hat Inc. <alan@redhat.com> 15 * The changes are (c) Copyright 2004, Red Hat Inc. <alan@lxorguk.ukuu.org.uk>
16 * Additional fixes and clean up: Francois Romieu 16 * Additional fixes and clean up: Francois Romieu
17 * 17 *
18 * This source has not been verified for use in safety critical systems. 18 * This source has not been verified for use in safety critical systems.
diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
index 243bd8d918fe..ccd9cd35ecbe 100644
--- a/drivers/net/wan/z85230.c
+++ b/drivers/net/wan/z85230.c
@@ -18,7 +18,8 @@
18 * DMA now uses get_free_page as kmalloc buffers may span a 64K 18 * DMA now uses get_free_page as kmalloc buffers may span a 64K
19 * boundary. 19 * boundary.
20 * 20 *
21 * Modified for SMP safety and SMP locking by Alan Cox <alan@redhat.com> 21 * Modified for SMP safety and SMP locking by Alan Cox
22 * <alan@lxorguk.ukuu.org.uk>
22 * 23 *
23 * Performance 24 * Performance
24 * 25 *
diff --git a/drivers/net/wan/z85230.h b/drivers/net/wan/z85230.h
index 4f372396c512..85b3e785d484 100644
--- a/drivers/net/wan/z85230.h
+++ b/drivers/net/wan/z85230.h
@@ -2,7 +2,7 @@
2 * Description of Z8530 Z85C30 and Z85230 communications chips 2 * Description of Z8530 Z85C30 and Z85230 communications chips
3 * 3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1998 Alan Cox <alan@redhat.com> 5 * Copyright (C) 1998 Alan Cox <alan@lxorguk.ukuu.org.uk>
6 */ 6 */
7 7
8#ifndef _Z8530_H 8#ifndef _Z8530_H
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index 136220b5ca81..e939a73ff794 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -4387,7 +4387,7 @@ MODULE_LICENSE("GPL");
4387 * 4387 *
4388 * Thanks go also to: 4388 * Thanks go also to:
4389 * James Ashton (jaa101@syseng.anu.edu.au), 4389 * James Ashton (jaa101@syseng.anu.edu.au),
4390 * Alan Cox (alan@redhat.com), 4390 * Alan Cox (alan@lxorguk.ukuu.org.uk),
4391 * Allan Creighton (allanc@cs.usyd.edu.au), 4391 * Allan Creighton (allanc@cs.usyd.edu.au),
4392 * Matthew Geier (matthew@cs.usyd.edu.au), 4392 * Matthew Geier (matthew@cs.usyd.edu.au),
4393 * Remo di Giovanni (remo@cs.usyd.edu.au), 4393 * Remo di Giovanni (remo@cs.usyd.edu.au),
diff --git a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
index b33ac47dd8df..44d31bbf39e4 100644
--- a/drivers/net/wireless/wavelan.p.h
+++ b/drivers/net/wireless/wavelan.p.h
@@ -186,7 +186,7 @@
186 * 186 *
187 * Thanks go also to: 187 * Thanks go also to:
188 * James Ashton <jaa101@syseng.anu.edu.au>, 188 * James Ashton <jaa101@syseng.anu.edu.au>,
189 * Alan Cox <alan@redhat.com>, 189 * Alan Cox <alan@lxorguk.ukuu.org.uk>,
190 * Allan Creighton <allanc@cs.usyd.edu.au>, 190 * Allan Creighton <allanc@cs.usyd.edu.au>,
191 * Matthew Geier <matthew@cs.usyd.edu.au>, 191 * Matthew Geier <matthew@cs.usyd.edu.au>,
192 * Remo di Giovanni <remo@cs.usyd.edu.au>, 192 * Remo di Giovanni <remo@cs.usyd.edu.au>,
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index a656128f1fdd..4dada6ee1119 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -56,4 +56,28 @@ config REGULATOR_BQ24022
56 charging select between 100 mA and 500 mA charging current 56 charging select between 100 mA and 500 mA charging current
57 limit. 57 limit.
58 58
59config REGULATOR_WM8350
60 tristate "Wolfson Microelectroncis WM8350 AudioPlus PMIC"
61 depends on MFD_WM8350
62 select REGULATOR
63 help
64 This driver provides support for the voltage and current regulators
65 of the WM8350 AudioPlus PMIC.
66
67config REGULATOR_WM8400
68 tristate "Wolfson Microelectroncis WM8400 AudioPlus PMIC"
69 depends on MFD_WM8400
70 select REGULATOR
71 help
72 This driver provides support for the voltage regulators of the
73 WM8400 AudioPlus PMIC.
74
75config REGULATOR_DA903X
76 tristate "Support regulators on Dialog Semiconductor DA9030/DA9034 PMIC"
77 depends on PMIC_DA903X
78 select REGULATOR
79 help
80 Say y here to support the BUCKs and LDOs regulators found on
81 Dialog Semiconductor DA9030/DA9034 PMIC.
82
59endmenu 83endmenu
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index ac2c64efe65c..254d40c02ee8 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -8,5 +8,8 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
8obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o 8obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
9 9
10obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o 10obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
11 14
12ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG 15ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c
index 263699d6152d..366565aba865 100644
--- a/drivers/regulator/bq24022.c
+++ b/drivers/regulator/bq24022.c
@@ -18,13 +18,13 @@
18#include <linux/regulator/bq24022.h> 18#include <linux/regulator/bq24022.h>
19#include <linux/regulator/driver.h> 19#include <linux/regulator/driver.h>
20 20
21
21static int bq24022_set_current_limit(struct regulator_dev *rdev, 22static int bq24022_set_current_limit(struct regulator_dev *rdev,
22 int min_uA, int max_uA) 23 int min_uA, int max_uA)
23{ 24{
24 struct platform_device *pdev = rdev_get_drvdata(rdev); 25 struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev);
25 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
26 26
27 dev_dbg(&pdev->dev, "setting current limit to %s mA\n", 27 dev_dbg(rdev_get_dev(rdev), "setting current limit to %s mA\n",
28 max_uA >= 500000 ? "500" : "100"); 28 max_uA >= 500000 ? "500" : "100");
29 29
30 /* REVISIT: maybe return error if min_uA != 0 ? */ 30 /* REVISIT: maybe return error if min_uA != 0 ? */
@@ -34,18 +34,16 @@ static int bq24022_set_current_limit(struct regulator_dev *rdev,
34 34
35static int bq24022_get_current_limit(struct regulator_dev *rdev) 35static int bq24022_get_current_limit(struct regulator_dev *rdev)
36{ 36{
37 struct platform_device *pdev = rdev_get_drvdata(rdev); 37 struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev);
38 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
39 38
40 return gpio_get_value(pdata->gpio_iset2) ? 500000 : 100000; 39 return gpio_get_value(pdata->gpio_iset2) ? 500000 : 100000;
41} 40}
42 41
43static int bq24022_enable(struct regulator_dev *rdev) 42static int bq24022_enable(struct regulator_dev *rdev)
44{ 43{
45 struct platform_device *pdev = rdev_get_drvdata(rdev); 44 struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev);
46 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
47 45
48 dev_dbg(&pdev->dev, "enabling charger\n"); 46 dev_dbg(rdev_get_dev(rdev), "enabling charger\n");
49 47
50 gpio_set_value(pdata->gpio_nce, 0); 48 gpio_set_value(pdata->gpio_nce, 0);
51 return 0; 49 return 0;
@@ -53,10 +51,9 @@ static int bq24022_enable(struct regulator_dev *rdev)
53 51
54static int bq24022_disable(struct regulator_dev *rdev) 52static int bq24022_disable(struct regulator_dev *rdev)
55{ 53{
56 struct platform_device *pdev = rdev_get_drvdata(rdev); 54 struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev);
57 struct bq24022_mach_info *pdata = pdev->dev.platform_data;
58 55
59 dev_dbg(&pdev->dev, "disabling charger\n"); 56 dev_dbg(rdev_get_dev(rdev), "disabling charger\n");
60 57
61 gpio_set_value(pdata->gpio_nce, 1); 58 gpio_set_value(pdata->gpio_nce, 1);
62 return 0; 59 return 0;
@@ -108,7 +105,7 @@ static int __init bq24022_probe(struct platform_device *pdev)
108 ret = gpio_direction_output(pdata->gpio_iset2, 0); 105 ret = gpio_direction_output(pdata->gpio_iset2, 0);
109 ret = gpio_direction_output(pdata->gpio_nce, 1); 106 ret = gpio_direction_output(pdata->gpio_nce, 1);
110 107
111 bq24022 = regulator_register(&bq24022_desc, pdev); 108 bq24022 = regulator_register(&bq24022_desc, &pdev->dev, pdata);
112 if (IS_ERR(bq24022)) { 109 if (IS_ERR(bq24022)) {
113 dev_dbg(&pdev->dev, "couldn't register regulator\n"); 110 dev_dbg(&pdev->dev, "couldn't register regulator\n");
114 ret = PTR_ERR(bq24022); 111 ret = PTR_ERR(bq24022);
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9c7986261568..02a774424e8d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2,8 +2,9 @@
2 * core.c -- Voltage/Current Regulator framework. 2 * core.c -- Voltage/Current Regulator framework.
3 * 3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC. 4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 * Copyright 2008 SlimLogic Ltd.
5 * 6 *
6 * Author: Liam Girdwood <liam.girdwood@wolfsonmicro.com> 7 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -64,14 +65,9 @@ struct regulator_map {
64 struct list_head list; 65 struct list_head list;
65 struct device *dev; 66 struct device *dev;
66 const char *supply; 67 const char *supply;
67 const char *regulator; 68 struct regulator_dev *regulator;
68}; 69};
69 70
70static inline struct regulator_dev *to_rdev(struct device *d)
71{
72 return container_of(d, struct regulator_dev, dev);
73}
74
75/* 71/*
76 * struct regulator 72 * struct regulator
77 * 73 *
@@ -227,7 +223,7 @@ static ssize_t device_requested_uA_show(struct device *dev,
227static ssize_t regulator_uV_show(struct device *dev, 223static ssize_t regulator_uV_show(struct device *dev,
228 struct device_attribute *attr, char *buf) 224 struct device_attribute *attr, char *buf)
229{ 225{
230 struct regulator_dev *rdev = to_rdev(dev); 226 struct regulator_dev *rdev = dev_get_drvdata(dev);
231 ssize_t ret; 227 ssize_t ret;
232 228
233 mutex_lock(&rdev->mutex); 229 mutex_lock(&rdev->mutex);
@@ -240,15 +236,31 @@ static ssize_t regulator_uV_show(struct device *dev,
240static ssize_t regulator_uA_show(struct device *dev, 236static ssize_t regulator_uA_show(struct device *dev,
241 struct device_attribute *attr, char *buf) 237 struct device_attribute *attr, char *buf)
242{ 238{
243 struct regulator_dev *rdev = to_rdev(dev); 239 struct regulator_dev *rdev = dev_get_drvdata(dev);
244 240
245 return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev)); 241 return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev));
246} 242}
247 243
244static ssize_t regulator_name_show(struct device *dev,
245 struct device_attribute *attr, char *buf)
246{
247 struct regulator_dev *rdev = dev_get_drvdata(dev);
248 const char *name;
249
250 if (rdev->constraints->name)
251 name = rdev->constraints->name;
252 else if (rdev->desc->name)
253 name = rdev->desc->name;
254 else
255 name = "";
256
257 return sprintf(buf, "%s\n", name);
258}
259
248static ssize_t regulator_opmode_show(struct device *dev, 260static ssize_t regulator_opmode_show(struct device *dev,
249 struct device_attribute *attr, char *buf) 261 struct device_attribute *attr, char *buf)
250{ 262{
251 struct regulator_dev *rdev = to_rdev(dev); 263 struct regulator_dev *rdev = dev_get_drvdata(dev);
252 int mode = _regulator_get_mode(rdev); 264 int mode = _regulator_get_mode(rdev);
253 265
254 switch (mode) { 266 switch (mode) {
@@ -267,7 +279,7 @@ static ssize_t regulator_opmode_show(struct device *dev,
267static ssize_t regulator_state_show(struct device *dev, 279static ssize_t regulator_state_show(struct device *dev,
268 struct device_attribute *attr, char *buf) 280 struct device_attribute *attr, char *buf)
269{ 281{
270 struct regulator_dev *rdev = to_rdev(dev); 282 struct regulator_dev *rdev = dev_get_drvdata(dev);
271 int state = _regulator_is_enabled(rdev); 283 int state = _regulator_is_enabled(rdev);
272 284
273 if (state > 0) 285 if (state > 0)
@@ -281,7 +293,7 @@ static ssize_t regulator_state_show(struct device *dev,
281static ssize_t regulator_min_uA_show(struct device *dev, 293static ssize_t regulator_min_uA_show(struct device *dev,
282 struct device_attribute *attr, char *buf) 294 struct device_attribute *attr, char *buf)
283{ 295{
284 struct regulator_dev *rdev = to_rdev(dev); 296 struct regulator_dev *rdev = dev_get_drvdata(dev);
285 297
286 if (!rdev->constraints) 298 if (!rdev->constraints)
287 return sprintf(buf, "constraint not defined\n"); 299 return sprintf(buf, "constraint not defined\n");
@@ -292,7 +304,7 @@ static ssize_t regulator_min_uA_show(struct device *dev,
292static ssize_t regulator_max_uA_show(struct device *dev, 304static ssize_t regulator_max_uA_show(struct device *dev,
293 struct device_attribute *attr, char *buf) 305 struct device_attribute *attr, char *buf)
294{ 306{
295 struct regulator_dev *rdev = to_rdev(dev); 307 struct regulator_dev *rdev = dev_get_drvdata(dev);
296 308
297 if (!rdev->constraints) 309 if (!rdev->constraints)
298 return sprintf(buf, "constraint not defined\n"); 310 return sprintf(buf, "constraint not defined\n");
@@ -303,7 +315,7 @@ static ssize_t regulator_max_uA_show(struct device *dev,
303static ssize_t regulator_min_uV_show(struct device *dev, 315static ssize_t regulator_min_uV_show(struct device *dev,
304 struct device_attribute *attr, char *buf) 316 struct device_attribute *attr, char *buf)
305{ 317{
306 struct regulator_dev *rdev = to_rdev(dev); 318 struct regulator_dev *rdev = dev_get_drvdata(dev);
307 319
308 if (!rdev->constraints) 320 if (!rdev->constraints)
309 return sprintf(buf, "constraint not defined\n"); 321 return sprintf(buf, "constraint not defined\n");
@@ -314,7 +326,7 @@ static ssize_t regulator_min_uV_show(struct device *dev,
314static ssize_t regulator_max_uV_show(struct device *dev, 326static ssize_t regulator_max_uV_show(struct device *dev,
315 struct device_attribute *attr, char *buf) 327 struct device_attribute *attr, char *buf)
316{ 328{
317 struct regulator_dev *rdev = to_rdev(dev); 329 struct regulator_dev *rdev = dev_get_drvdata(dev);
318 330
319 if (!rdev->constraints) 331 if (!rdev->constraints)
320 return sprintf(buf, "constraint not defined\n"); 332 return sprintf(buf, "constraint not defined\n");
@@ -325,7 +337,7 @@ static ssize_t regulator_max_uV_show(struct device *dev,
325static ssize_t regulator_total_uA_show(struct device *dev, 337static ssize_t regulator_total_uA_show(struct device *dev,
326 struct device_attribute *attr, char *buf) 338 struct device_attribute *attr, char *buf)
327{ 339{
328 struct regulator_dev *rdev = to_rdev(dev); 340 struct regulator_dev *rdev = dev_get_drvdata(dev);
329 struct regulator *regulator; 341 struct regulator *regulator;
330 int uA = 0; 342 int uA = 0;
331 343
@@ -339,14 +351,14 @@ static ssize_t regulator_total_uA_show(struct device *dev,
339static ssize_t regulator_num_users_show(struct device *dev, 351static ssize_t regulator_num_users_show(struct device *dev,
340 struct device_attribute *attr, char *buf) 352 struct device_attribute *attr, char *buf)
341{ 353{
342 struct regulator_dev *rdev = to_rdev(dev); 354 struct regulator_dev *rdev = dev_get_drvdata(dev);
343 return sprintf(buf, "%d\n", rdev->use_count); 355 return sprintf(buf, "%d\n", rdev->use_count);
344} 356}
345 357
346static ssize_t regulator_type_show(struct device *dev, 358static ssize_t regulator_type_show(struct device *dev,
347 struct device_attribute *attr, char *buf) 359 struct device_attribute *attr, char *buf)
348{ 360{
349 struct regulator_dev *rdev = to_rdev(dev); 361 struct regulator_dev *rdev = dev_get_drvdata(dev);
350 362
351 switch (rdev->desc->type) { 363 switch (rdev->desc->type) {
352 case REGULATOR_VOLTAGE: 364 case REGULATOR_VOLTAGE:
@@ -360,7 +372,7 @@ static ssize_t regulator_type_show(struct device *dev,
360static ssize_t regulator_suspend_mem_uV_show(struct device *dev, 372static ssize_t regulator_suspend_mem_uV_show(struct device *dev,
361 struct device_attribute *attr, char *buf) 373 struct device_attribute *attr, char *buf)
362{ 374{
363 struct regulator_dev *rdev = to_rdev(dev); 375 struct regulator_dev *rdev = dev_get_drvdata(dev);
364 376
365 if (!rdev->constraints) 377 if (!rdev->constraints)
366 return sprintf(buf, "not defined\n"); 378 return sprintf(buf, "not defined\n");
@@ -370,7 +382,7 @@ static ssize_t regulator_suspend_mem_uV_show(struct device *dev,
370static ssize_t regulator_suspend_disk_uV_show(struct device *dev, 382static ssize_t regulator_suspend_disk_uV_show(struct device *dev,
371 struct device_attribute *attr, char *buf) 383 struct device_attribute *attr, char *buf)
372{ 384{
373 struct regulator_dev *rdev = to_rdev(dev); 385 struct regulator_dev *rdev = dev_get_drvdata(dev);
374 386
375 if (!rdev->constraints) 387 if (!rdev->constraints)
376 return sprintf(buf, "not defined\n"); 388 return sprintf(buf, "not defined\n");
@@ -380,7 +392,7 @@ static ssize_t regulator_suspend_disk_uV_show(struct device *dev,
380static ssize_t regulator_suspend_standby_uV_show(struct device *dev, 392static ssize_t regulator_suspend_standby_uV_show(struct device *dev,
381 struct device_attribute *attr, char *buf) 393 struct device_attribute *attr, char *buf)
382{ 394{
383 struct regulator_dev *rdev = to_rdev(dev); 395 struct regulator_dev *rdev = dev_get_drvdata(dev);
384 396
385 if (!rdev->constraints) 397 if (!rdev->constraints)
386 return sprintf(buf, "not defined\n"); 398 return sprintf(buf, "not defined\n");
@@ -406,7 +418,7 @@ static ssize_t suspend_opmode_show(struct regulator_dev *rdev,
406static ssize_t regulator_suspend_mem_mode_show(struct device *dev, 418static ssize_t regulator_suspend_mem_mode_show(struct device *dev,
407 struct device_attribute *attr, char *buf) 419 struct device_attribute *attr, char *buf)
408{ 420{
409 struct regulator_dev *rdev = to_rdev(dev); 421 struct regulator_dev *rdev = dev_get_drvdata(dev);
410 422
411 if (!rdev->constraints) 423 if (!rdev->constraints)
412 return sprintf(buf, "not defined\n"); 424 return sprintf(buf, "not defined\n");
@@ -417,7 +429,7 @@ static ssize_t regulator_suspend_mem_mode_show(struct device *dev,
417static ssize_t regulator_suspend_disk_mode_show(struct device *dev, 429static ssize_t regulator_suspend_disk_mode_show(struct device *dev,
418 struct device_attribute *attr, char *buf) 430 struct device_attribute *attr, char *buf)
419{ 431{
420 struct regulator_dev *rdev = to_rdev(dev); 432 struct regulator_dev *rdev = dev_get_drvdata(dev);
421 433
422 if (!rdev->constraints) 434 if (!rdev->constraints)
423 return sprintf(buf, "not defined\n"); 435 return sprintf(buf, "not defined\n");
@@ -428,7 +440,7 @@ static ssize_t regulator_suspend_disk_mode_show(struct device *dev,
428static ssize_t regulator_suspend_standby_mode_show(struct device *dev, 440static ssize_t regulator_suspend_standby_mode_show(struct device *dev,
429 struct device_attribute *attr, char *buf) 441 struct device_attribute *attr, char *buf)
430{ 442{
431 struct regulator_dev *rdev = to_rdev(dev); 443 struct regulator_dev *rdev = dev_get_drvdata(dev);
432 444
433 if (!rdev->constraints) 445 if (!rdev->constraints)
434 return sprintf(buf, "not defined\n"); 446 return sprintf(buf, "not defined\n");
@@ -439,7 +451,7 @@ static ssize_t regulator_suspend_standby_mode_show(struct device *dev,
439static ssize_t regulator_suspend_mem_state_show(struct device *dev, 451static ssize_t regulator_suspend_mem_state_show(struct device *dev,
440 struct device_attribute *attr, char *buf) 452 struct device_attribute *attr, char *buf)
441{ 453{
442 struct regulator_dev *rdev = to_rdev(dev); 454 struct regulator_dev *rdev = dev_get_drvdata(dev);
443 455
444 if (!rdev->constraints) 456 if (!rdev->constraints)
445 return sprintf(buf, "not defined\n"); 457 return sprintf(buf, "not defined\n");
@@ -453,7 +465,7 @@ static ssize_t regulator_suspend_mem_state_show(struct device *dev,
453static ssize_t regulator_suspend_disk_state_show(struct device *dev, 465static ssize_t regulator_suspend_disk_state_show(struct device *dev,
454 struct device_attribute *attr, char *buf) 466 struct device_attribute *attr, char *buf)
455{ 467{
456 struct regulator_dev *rdev = to_rdev(dev); 468 struct regulator_dev *rdev = dev_get_drvdata(dev);
457 469
458 if (!rdev->constraints) 470 if (!rdev->constraints)
459 return sprintf(buf, "not defined\n"); 471 return sprintf(buf, "not defined\n");
@@ -467,7 +479,7 @@ static ssize_t regulator_suspend_disk_state_show(struct device *dev,
467static ssize_t regulator_suspend_standby_state_show(struct device *dev, 479static ssize_t regulator_suspend_standby_state_show(struct device *dev,
468 struct device_attribute *attr, char *buf) 480 struct device_attribute *attr, char *buf)
469{ 481{
470 struct regulator_dev *rdev = to_rdev(dev); 482 struct regulator_dev *rdev = dev_get_drvdata(dev);
471 483
472 if (!rdev->constraints) 484 if (!rdev->constraints)
473 return sprintf(buf, "not defined\n"); 485 return sprintf(buf, "not defined\n");
@@ -477,7 +489,9 @@ static ssize_t regulator_suspend_standby_state_show(struct device *dev,
477 else 489 else
478 return sprintf(buf, "disabled\n"); 490 return sprintf(buf, "disabled\n");
479} 491}
492
480static struct device_attribute regulator_dev_attrs[] = { 493static struct device_attribute regulator_dev_attrs[] = {
494 __ATTR(name, 0444, regulator_name_show, NULL),
481 __ATTR(microvolts, 0444, regulator_uV_show, NULL), 495 __ATTR(microvolts, 0444, regulator_uV_show, NULL),
482 __ATTR(microamps, 0444, regulator_uA_show, NULL), 496 __ATTR(microamps, 0444, regulator_uA_show, NULL),
483 __ATTR(opmode, 0444, regulator_opmode_show, NULL), 497 __ATTR(opmode, 0444, regulator_opmode_show, NULL),
@@ -512,7 +526,7 @@ static struct device_attribute regulator_dev_attrs[] = {
512 526
513static void regulator_dev_release(struct device *dev) 527static void regulator_dev_release(struct device *dev)
514{ 528{
515 struct regulator_dev *rdev = to_rdev(dev); 529 struct regulator_dev *rdev = dev_get_drvdata(dev);
516 kfree(rdev); 530 kfree(rdev);
517} 531}
518 532
@@ -569,8 +583,11 @@ static int suspend_set_state(struct regulator_dev *rdev,
569 583
570 /* enable & disable are mandatory for suspend control */ 584 /* enable & disable are mandatory for suspend control */
571 if (!rdev->desc->ops->set_suspend_enable || 585 if (!rdev->desc->ops->set_suspend_enable ||
572 !rdev->desc->ops->set_suspend_disable) 586 !rdev->desc->ops->set_suspend_disable) {
587 printk(KERN_ERR "%s: no way to set suspend state\n",
588 __func__);
573 return -EINVAL; 589 return -EINVAL;
590 }
574 591
575 if (rstate->enabled) 592 if (rstate->enabled)
576 ret = rdev->desc->ops->set_suspend_enable(rdev); 593 ret = rdev->desc->ops->set_suspend_enable(rdev);
@@ -656,6 +673,155 @@ static void print_constraints(struct regulator_dev *rdev)
656 printk(KERN_INFO "regulator: %s: %s\n", rdev->desc->name, buf); 673 printk(KERN_INFO "regulator: %s: %s\n", rdev->desc->name, buf);
657} 674}
658 675
676/**
677 * set_machine_constraints - sets regulator constraints
678 * @regulator: regulator source
679 *
680 * Allows platform initialisation code to define and constrain
681 * regulator circuits e.g. valid voltage/current ranges, etc. NOTE:
682 * Constraints *must* be set by platform code in order for some
683 * regulator operations to proceed i.e. set_voltage, set_current_limit,
684 * set_mode.
685 */
686static int set_machine_constraints(struct regulator_dev *rdev,
687 struct regulation_constraints *constraints)
688{
689 int ret = 0;
690 const char *name;
691 struct regulator_ops *ops = rdev->desc->ops;
692
693 if (constraints->name)
694 name = constraints->name;
695 else if (rdev->desc->name)
696 name = rdev->desc->name;
697 else
698 name = "regulator";
699
700 rdev->constraints = constraints;
701
702 /* do we need to apply the constraint voltage */
703 if (rdev->constraints->apply_uV &&
704 rdev->constraints->min_uV == rdev->constraints->max_uV &&
705 ops->set_voltage) {
706 ret = ops->set_voltage(rdev,
707 rdev->constraints->min_uV, rdev->constraints->max_uV);
708 if (ret < 0) {
709 printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n",
710 __func__,
711 rdev->constraints->min_uV, name);
712 rdev->constraints = NULL;
713 goto out;
714 }
715 }
716
717 /* are we enabled at boot time by firmware / bootloader */
718 if (rdev->constraints->boot_on)
719 rdev->use_count = 1;
720
721 /* do we need to setup our suspend state */
722 if (constraints->initial_state) {
723 ret = suspend_prepare(rdev, constraints->initial_state);
724 if (ret < 0) {
725 printk(KERN_ERR "%s: failed to set suspend state for %s\n",
726 __func__, name);
727 rdev->constraints = NULL;
728 goto out;
729 }
730 }
731
732 /* if always_on is set then turn the regulator on if it's not
733 * already on. */
734 if (constraints->always_on && ops->enable &&
735 ((ops->is_enabled && !ops->is_enabled(rdev)) ||
736 (!ops->is_enabled && !constraints->boot_on))) {
737 ret = ops->enable(rdev);
738 if (ret < 0) {
739 printk(KERN_ERR "%s: failed to enable %s\n",
740 __func__, name);
741 rdev->constraints = NULL;
742 goto out;
743 }
744 }
745
746 print_constraints(rdev);
747out:
748 return ret;
749}
750
751/**
752 * set_supply - set regulator supply regulator
753 * @regulator: regulator name
754 * @supply: supply regulator name
755 *
756 * Called by platform initialisation code to set the supply regulator for this
757 * regulator. This ensures that a regulators supply will also be enabled by the
758 * core if it's child is enabled.
759 */
760static int set_supply(struct regulator_dev *rdev,
761 struct regulator_dev *supply_rdev)
762{
763 int err;
764
765 err = sysfs_create_link(&rdev->dev.kobj, &supply_rdev->dev.kobj,
766 "supply");
767 if (err) {
768 printk(KERN_ERR
769 "%s: could not add device link %s err %d\n",
770 __func__, supply_rdev->dev.kobj.name, err);
771 goto out;
772 }
773 rdev->supply = supply_rdev;
774 list_add(&rdev->slist, &supply_rdev->supply_list);
775out:
776 return err;
777}
778
779/**
780 * set_consumer_device_supply: Bind a regulator to a symbolic supply
781 * @regulator: regulator source
782 * @dev: device the supply applies to
783 * @supply: symbolic name for supply
784 *
785 * Allows platform initialisation code to map physical regulator
786 * sources to symbolic names for supplies for use by devices. Devices
787 * should use these symbolic names to request regulators, avoiding the
788 * need to provide board-specific regulator names as platform data.
789 */
790static int set_consumer_device_supply(struct regulator_dev *rdev,
791 struct device *consumer_dev, const char *supply)
792{
793 struct regulator_map *node;
794
795 if (supply == NULL)
796 return -EINVAL;
797
798 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
799 if (node == NULL)
800 return -ENOMEM;
801
802 node->regulator = rdev;
803 node->dev = consumer_dev;
804 node->supply = supply;
805
806 list_add(&node->list, &regulator_map_list);
807 return 0;
808}
809
810static void unset_consumer_device_supply(struct regulator_dev *rdev,
811 struct device *consumer_dev)
812{
813 struct regulator_map *node, *n;
814
815 list_for_each_entry_safe(node, n, &regulator_map_list, list) {
816 if (rdev == node->regulator &&
817 consumer_dev == node->dev) {
818 list_del(&node->list);
819 kfree(node);
820 return;
821 }
822 }
823}
824
659#define REG_STR_SIZE 32 825#define REG_STR_SIZE 32
660 826
661static struct regulator *create_regulator(struct regulator_dev *rdev, 827static struct regulator *create_regulator(struct regulator_dev *rdev,
@@ -746,7 +912,6 @@ struct regulator *regulator_get(struct device *dev, const char *id)
746 struct regulator_dev *rdev; 912 struct regulator_dev *rdev;
747 struct regulator_map *map; 913 struct regulator_map *map;
748 struct regulator *regulator = ERR_PTR(-ENODEV); 914 struct regulator *regulator = ERR_PTR(-ENODEV);
749 const char *supply = id;
750 915
751 if (id == NULL) { 916 if (id == NULL) {
752 printk(KERN_ERR "regulator: get() with no identifier\n"); 917 printk(KERN_ERR "regulator: get() with no identifier\n");
@@ -758,15 +923,9 @@ struct regulator *regulator_get(struct device *dev, const char *id)
758 list_for_each_entry(map, &regulator_map_list, list) { 923 list_for_each_entry(map, &regulator_map_list, list) {
759 if (dev == map->dev && 924 if (dev == map->dev &&
760 strcmp(map->supply, id) == 0) { 925 strcmp(map->supply, id) == 0) {
761 supply = map->regulator; 926 rdev = map->regulator;
762 break;
763 }
764 }
765
766 list_for_each_entry(rdev, &regulator_list, list) {
767 if (strcmp(supply, rdev->desc->name) == 0 &&
768 try_module_get(rdev->owner))
769 goto found; 927 goto found;
928 }
770 } 929 }
771 printk(KERN_ERR "regulator: Unable to get requested regulator: %s\n", 930 printk(KERN_ERR "regulator: Unable to get requested regulator: %s\n",
772 id); 931 id);
@@ -774,12 +933,16 @@ struct regulator *regulator_get(struct device *dev, const char *id)
774 return regulator; 933 return regulator;
775 934
776found: 935found:
936 if (!try_module_get(rdev->owner))
937 goto out;
938
777 regulator = create_regulator(rdev, dev, id); 939 regulator = create_regulator(rdev, dev, id);
778 if (regulator == NULL) { 940 if (regulator == NULL) {
779 regulator = ERR_PTR(-ENOMEM); 941 regulator = ERR_PTR(-ENOMEM);
780 module_put(rdev->owner); 942 module_put(rdev->owner);
781 } 943 }
782 944
945out:
783 mutex_unlock(&regulator_list_mutex); 946 mutex_unlock(&regulator_list_mutex);
784 return regulator; 947 return regulator;
785} 948}
@@ -1559,11 +1722,12 @@ EXPORT_SYMBOL_GPL(regulator_notifier_call_chain);
1559 * Returns 0 on success. 1722 * Returns 0 on success.
1560 */ 1723 */
1561struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, 1724struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1562 void *reg_data) 1725 struct device *dev, void *driver_data)
1563{ 1726{
1564 static atomic_t regulator_no = ATOMIC_INIT(0); 1727 static atomic_t regulator_no = ATOMIC_INIT(0);
1565 struct regulator_dev *rdev; 1728 struct regulator_dev *rdev;
1566 int ret; 1729 struct regulator_init_data *init_data = dev->platform_data;
1730 int ret, i;
1567 1731
1568 if (regulator_desc == NULL) 1732 if (regulator_desc == NULL)
1569 return ERR_PTR(-EINVAL); 1733 return ERR_PTR(-EINVAL);
@@ -1575,6 +1739,9 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1575 !regulator_desc->type == REGULATOR_CURRENT) 1739 !regulator_desc->type == REGULATOR_CURRENT)
1576 return ERR_PTR(-EINVAL); 1740 return ERR_PTR(-EINVAL);
1577 1741
1742 if (!init_data)
1743 return ERR_PTR(-EINVAL);
1744
1578 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL); 1745 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL);
1579 if (rdev == NULL) 1746 if (rdev == NULL)
1580 return ERR_PTR(-ENOMEM); 1747 return ERR_PTR(-ENOMEM);
@@ -1582,7 +1749,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1582 mutex_lock(&regulator_list_mutex); 1749 mutex_lock(&regulator_list_mutex);
1583 1750
1584 mutex_init(&rdev->mutex); 1751 mutex_init(&rdev->mutex);
1585 rdev->reg_data = reg_data; 1752 rdev->reg_data = driver_data;
1586 rdev->owner = regulator_desc->owner; 1753 rdev->owner = regulator_desc->owner;
1587 rdev->desc = regulator_desc; 1754 rdev->desc = regulator_desc;
1588 INIT_LIST_HEAD(&rdev->consumer_list); 1755 INIT_LIST_HEAD(&rdev->consumer_list);
@@ -1591,20 +1758,68 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1591 INIT_LIST_HEAD(&rdev->slist); 1758 INIT_LIST_HEAD(&rdev->slist);
1592 BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier); 1759 BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier);
1593 1760
1761 /* preform any regulator specific init */
1762 if (init_data->regulator_init) {
1763 ret = init_data->regulator_init(rdev->reg_data);
1764 if (ret < 0) {
1765 kfree(rdev);
1766 rdev = ERR_PTR(ret);
1767 goto out;
1768 }
1769 }
1770
1771 /* set regulator constraints */
1772 ret = set_machine_constraints(rdev, &init_data->constraints);
1773 if (ret < 0) {
1774 kfree(rdev);
1775 rdev = ERR_PTR(ret);
1776 goto out;
1777 }
1778
1779 /* register with sysfs */
1594 rdev->dev.class = &regulator_class; 1780 rdev->dev.class = &regulator_class;
1595 device_initialize(&rdev->dev); 1781 rdev->dev.parent = dev;
1596 snprintf(rdev->dev.bus_id, sizeof(rdev->dev.bus_id), 1782 snprintf(rdev->dev.bus_id, sizeof(rdev->dev.bus_id),
1597 "regulator_%ld_%s", 1783 "regulator.%d", atomic_inc_return(&regulator_no) - 1);
1598 (unsigned long)atomic_inc_return(&regulator_no) - 1, 1784 ret = device_register(&rdev->dev);
1599 regulator_desc->name); 1785 if (ret != 0) {
1600
1601 ret = device_add(&rdev->dev);
1602 if (ret == 0)
1603 list_add(&rdev->list, &regulator_list);
1604 else {
1605 kfree(rdev); 1786 kfree(rdev);
1606 rdev = ERR_PTR(ret); 1787 rdev = ERR_PTR(ret);
1788 goto out;
1789 }
1790
1791 dev_set_drvdata(&rdev->dev, rdev);
1792
1793 /* set supply regulator if it exists */
1794 if (init_data->supply_regulator_dev) {
1795 ret = set_supply(rdev,
1796 dev_get_drvdata(init_data->supply_regulator_dev));
1797 if (ret < 0) {
1798 device_unregister(&rdev->dev);
1799 kfree(rdev);
1800 rdev = ERR_PTR(ret);
1801 goto out;
1802 }
1607 } 1803 }
1804
1805 /* add consumers devices */
1806 for (i = 0; i < init_data->num_consumer_supplies; i++) {
1807 ret = set_consumer_device_supply(rdev,
1808 init_data->consumer_supplies[i].dev,
1809 init_data->consumer_supplies[i].supply);
1810 if (ret < 0) {
1811 for (--i; i >= 0; i--)
1812 unset_consumer_device_supply(rdev,
1813 init_data->consumer_supplies[i].dev);
1814 device_unregister(&rdev->dev);
1815 kfree(rdev);
1816 rdev = ERR_PTR(ret);
1817 goto out;
1818 }
1819 }
1820
1821 list_add(&rdev->list, &regulator_list);
1822out:
1608 mutex_unlock(&regulator_list_mutex); 1823 mutex_unlock(&regulator_list_mutex);
1609 return rdev; 1824 return rdev;
1610} 1825}
@@ -1631,187 +1846,6 @@ void regulator_unregister(struct regulator_dev *rdev)
1631EXPORT_SYMBOL_GPL(regulator_unregister); 1846EXPORT_SYMBOL_GPL(regulator_unregister);
1632 1847
1633/** 1848/**
1634 * regulator_set_supply - set regulator supply regulator
1635 * @regulator: regulator name
1636 * @supply: supply regulator name
1637 *
1638 * Called by platform initialisation code to set the supply regulator for this
1639 * regulator. This ensures that a regulators supply will also be enabled by the
1640 * core if it's child is enabled.
1641 */
1642int regulator_set_supply(const char *regulator, const char *supply)
1643{
1644 struct regulator_dev *rdev, *supply_rdev;
1645 int err;
1646
1647 if (regulator == NULL || supply == NULL)
1648 return -EINVAL;
1649
1650 mutex_lock(&regulator_list_mutex);
1651
1652 list_for_each_entry(rdev, &regulator_list, list) {
1653 if (!strcmp(rdev->desc->name, regulator))
1654 goto found_regulator;
1655 }
1656 mutex_unlock(&regulator_list_mutex);
1657 return -ENODEV;
1658
1659found_regulator:
1660 list_for_each_entry(supply_rdev, &regulator_list, list) {
1661 if (!strcmp(supply_rdev->desc->name, supply))
1662 goto found_supply;
1663 }
1664 mutex_unlock(&regulator_list_mutex);
1665 return -ENODEV;
1666
1667found_supply:
1668 err = sysfs_create_link(&rdev->dev.kobj, &supply_rdev->dev.kobj,
1669 "supply");
1670 if (err) {
1671 printk(KERN_ERR
1672 "%s: could not add device link %s err %d\n",
1673 __func__, supply_rdev->dev.kobj.name, err);
1674 goto out;
1675 }
1676 rdev->supply = supply_rdev;
1677 list_add(&rdev->slist, &supply_rdev->supply_list);
1678out:
1679 mutex_unlock(&regulator_list_mutex);
1680 return err;
1681}
1682EXPORT_SYMBOL_GPL(regulator_set_supply);
1683
1684/**
1685 * regulator_get_supply - get regulator supply regulator
1686 * @regulator: regulator name
1687 *
1688 * Returns the supply supply regulator name or NULL if no supply regulator
1689 * exists (i.e the regulator is supplied directly from USB, Line, Battery, etc)
1690 */
1691const char *regulator_get_supply(const char *regulator)
1692{
1693 struct regulator_dev *rdev;
1694
1695 if (regulator == NULL)
1696 return NULL;
1697
1698 mutex_lock(&regulator_list_mutex);
1699 list_for_each_entry(rdev, &regulator_list, list) {
1700 if (!strcmp(rdev->desc->name, regulator))
1701 goto found;
1702 }
1703 mutex_unlock(&regulator_list_mutex);
1704 return NULL;
1705
1706found:
1707 mutex_unlock(&regulator_list_mutex);
1708 if (rdev->supply)
1709 return rdev->supply->desc->name;
1710 else
1711 return NULL;
1712}
1713EXPORT_SYMBOL_GPL(regulator_get_supply);
1714
1715/**
1716 * regulator_set_machine_constraints - sets regulator constraints
1717 * @regulator: regulator source
1718 *
1719 * Allows platform initialisation code to define and constrain
1720 * regulator circuits e.g. valid voltage/current ranges, etc. NOTE:
1721 * Constraints *must* be set by platform code in order for some
1722 * regulator operations to proceed i.e. set_voltage, set_current_limit,
1723 * set_mode.
1724 */
1725int regulator_set_machine_constraints(const char *regulator_name,
1726 struct regulation_constraints *constraints)
1727{
1728 struct regulator_dev *rdev;
1729 int ret = 0;
1730
1731 if (regulator_name == NULL)
1732 return -EINVAL;
1733
1734 mutex_lock(&regulator_list_mutex);
1735
1736 list_for_each_entry(rdev, &regulator_list, list) {
1737 if (!strcmp(regulator_name, rdev->desc->name))
1738 goto found;
1739 }
1740 ret = -ENODEV;
1741 goto out;
1742
1743found:
1744 mutex_lock(&rdev->mutex);
1745 rdev->constraints = constraints;
1746
1747 /* do we need to apply the constraint voltage */
1748 if (rdev->constraints->apply_uV &&
1749 rdev->constraints->min_uV == rdev->constraints->max_uV &&
1750 rdev->desc->ops->set_voltage) {
1751 ret = rdev->desc->ops->set_voltage(rdev,
1752 rdev->constraints->min_uV, rdev->constraints->max_uV);
1753 if (ret < 0) {
1754 printk(KERN_ERR "%s: failed to apply %duV"
1755 " constraint\n", __func__,
1756 rdev->constraints->min_uV);
1757 rdev->constraints = NULL;
1758 goto out;
1759 }
1760 }
1761
1762 /* are we enabled at boot time by firmware / bootloader */
1763 if (rdev->constraints->boot_on)
1764 rdev->use_count = 1;
1765
1766 /* do we need to setup our suspend state */
1767 if (constraints->initial_state)
1768 ret = suspend_prepare(rdev, constraints->initial_state);
1769
1770 print_constraints(rdev);
1771 mutex_unlock(&rdev->mutex);
1772
1773out:
1774 mutex_unlock(&regulator_list_mutex);
1775 return ret;
1776}
1777EXPORT_SYMBOL_GPL(regulator_set_machine_constraints);
1778
1779
1780/**
1781 * regulator_set_device_supply: Bind a regulator to a symbolic supply
1782 * @regulator: regulator source
1783 * @dev: device the supply applies to
1784 * @supply: symbolic name for supply
1785 *
1786 * Allows platform initialisation code to map physical regulator
1787 * sources to symbolic names for supplies for use by devices. Devices
1788 * should use these symbolic names to request regulators, avoiding the
1789 * need to provide board-specific regulator names as platform data.
1790 */
1791int regulator_set_device_supply(const char *regulator, struct device *dev,
1792 const char *supply)
1793{
1794 struct regulator_map *node;
1795
1796 if (regulator == NULL || supply == NULL)
1797 return -EINVAL;
1798
1799 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
1800 if (node == NULL)
1801 return -ENOMEM;
1802
1803 node->regulator = regulator;
1804 node->dev = dev;
1805 node->supply = supply;
1806
1807 mutex_lock(&regulator_list_mutex);
1808 list_add(&node->list, &regulator_map_list);
1809 mutex_unlock(&regulator_list_mutex);
1810 return 0;
1811}
1812EXPORT_SYMBOL_GPL(regulator_set_device_supply);
1813
1814/**
1815 * regulator_suspend_prepare: prepare regulators for system wide suspend 1849 * regulator_suspend_prepare: prepare regulators for system wide suspend
1816 * @state: system suspend state 1850 * @state: system suspend state
1817 * 1851 *
@@ -1893,6 +1927,18 @@ int rdev_get_id(struct regulator_dev *rdev)
1893} 1927}
1894EXPORT_SYMBOL_GPL(rdev_get_id); 1928EXPORT_SYMBOL_GPL(rdev_get_id);
1895 1929
1930struct device *rdev_get_dev(struct regulator_dev *rdev)
1931{
1932 return &rdev->dev;
1933}
1934EXPORT_SYMBOL_GPL(rdev_get_dev);
1935
1936void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
1937{
1938 return reg_init_data->driver_data;
1939}
1940EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
1941
1896static int __init regulator_init(void) 1942static int __init regulator_init(void)
1897{ 1943{
1898 printk(KERN_INFO "regulator: core version %s\n", REGULATOR_VERSION); 1944 printk(KERN_INFO "regulator: core version %s\n", REGULATOR_VERSION);
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
new file mode 100644
index 000000000000..3688e339db87
--- /dev/null
+++ b/drivers/regulator/da903x.c
@@ -0,0 +1,513 @@
1/*
2 * Regulators driver for Dialog Semiconductor DA903x
3 *
4 * Copyright (C) 2006-2008 Marvell International Ltd.
5 * Copyright (C) 2008 Compulab Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/err.h>
15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h>
18#include <linux/mfd/da903x.h>
19
20/* DA9030 Registers */
21#define DA9030_INVAL (-1)
22#define DA9030_LDO1011 (0x10)
23#define DA9030_LDO15 (0x11)
24#define DA9030_LDO1416 (0x12)
25#define DA9030_LDO1819 (0x13)
26#define DA9030_LDO17 (0x14)
27#define DA9030_BUCK2DVM1 (0x15)
28#define DA9030_BUCK2DVM2 (0x16)
29#define DA9030_RCTL11 (0x17)
30#define DA9030_RCTL21 (0x18)
31#define DA9030_LDO1 (0x90)
32#define DA9030_LDO23 (0x91)
33#define DA9030_LDO45 (0x92)
34#define DA9030_LDO6 (0x93)
35#define DA9030_LDO78 (0x94)
36#define DA9030_LDO912 (0x95)
37#define DA9030_BUCK (0x96)
38#define DA9030_RCTL12 (0x97)
39#define DA9030_RCTL22 (0x98)
40#define DA9030_LDO_UNLOCK (0xa0)
41#define DA9030_LDO_UNLOCK_MASK (0xe0)
42#define DA9034_OVER1 (0x10)
43
44/* DA9034 Registers */
45#define DA9034_INVAL (-1)
46#define DA9034_OVER2 (0x11)
47#define DA9034_OVER3 (0x12)
48#define DA9034_LDO643 (0x13)
49#define DA9034_LDO987 (0x14)
50#define DA9034_LDO1110 (0x15)
51#define DA9034_LDO1312 (0x16)
52#define DA9034_LDO1514 (0x17)
53#define DA9034_VCC1 (0x20)
54#define DA9034_ADTV1 (0x23)
55#define DA9034_ADTV2 (0x24)
56#define DA9034_AVRC (0x25)
57#define DA9034_CDTV1 (0x26)
58#define DA9034_CDTV2 (0x27)
59#define DA9034_CVRC (0x28)
60#define DA9034_SDTV1 (0x29)
61#define DA9034_SDTV2 (0x2a)
62#define DA9034_SVRC (0x2b)
63#define DA9034_MDTV1 (0x32)
64#define DA9034_MDTV2 (0x33)
65#define DA9034_MVRC (0x34)
66
67struct da903x_regulator_info {
68 struct regulator_desc desc;
69
70 int min_uV;
71 int max_uV;
72 int step_uV;
73 int vol_reg;
74 int vol_shift;
75 int vol_nbits;
76 int update_reg;
77 int update_bit;
78 int enable_reg;
79 int enable_bit;
80};
81
82static inline int check_range(struct da903x_regulator_info *info,
83 int min_uV, int max_uV)
84{
85 if (min_uV < info->min_uV || min_uV > info->max_uV)
86 return -EINVAL;
87
88 return 0;
89}
90
91/* DA9030/DA9034 common operations */
92static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
93 int min_uV, int max_uV)
94{
95 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
96 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
97 uint8_t val, mask;
98
99 if (check_range(info, min_uV, max_uV)) {
100 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV);
101 return -EINVAL;
102 }
103
104 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
105 val <<= info->vol_shift;
106 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
107
108 return da903x_update(da9034_dev, info->vol_reg, val, mask);
109}
110
111static int da903x_get_voltage(struct regulator_dev *rdev)
112{
113 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
114 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
115 uint8_t val, mask;
116 int ret;
117
118 ret = da903x_read(da9034_dev, info->vol_reg, &val);
119 if (ret)
120 return ret;
121
122 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
123 val = (val & mask) >> info->vol_shift;
124
125 return info->min_uV + info->step_uV * val;
126}
127
128static int da903x_enable(struct regulator_dev *rdev)
129{
130 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
131 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
132
133 return da903x_set_bits(da9034_dev, info->enable_reg,
134 1 << info->enable_bit);
135}
136
137static int da903x_disable(struct regulator_dev *rdev)
138{
139 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
140 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
141
142 return da903x_clr_bits(da9034_dev, info->enable_reg,
143 1 << info->enable_bit);
144}
145
146static int da903x_is_enabled(struct regulator_dev *rdev)
147{
148 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
149 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
150 uint8_t reg_val;
151 int ret;
152
153 ret = da903x_read(da9034_dev, info->enable_reg, &reg_val);
154 if (ret)
155 return ret;
156
157 return reg_val & (1 << info->enable_bit);
158}
159
160/* DA9030 specific operations */
161static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
162 int min_uV, int max_uV)
163{
164 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
165 struct device *da903x_dev = rdev_get_dev(rdev)->parent;
166 uint8_t val, mask;
167 int ret;
168
169 if (check_range(info, min_uV, max_uV)) {
170 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV);
171 return -EINVAL;
172 }
173
174 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
175 val <<= info->vol_shift;
176 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
177 val |= DA9030_LDO_UNLOCK; /* have to set UNLOCK bits */
178 mask |= DA9030_LDO_UNLOCK_MASK;
179
180 /* write twice */
181 ret = da903x_update(da903x_dev, info->vol_reg, val, mask);
182 if (ret)
183 return ret;
184
185 return da903x_update(da903x_dev, info->vol_reg, val, mask);
186}
187
188static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
189 int min_uV, int max_uV)
190{
191 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
192 struct device *da903x_dev = rdev_get_dev(rdev)->parent;
193 uint8_t val, mask;
194 int thresh;
195
196 if (check_range(info, min_uV, max_uV)) {
197 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV);
198 return -EINVAL;
199 }
200
201 thresh = (info->max_uV + info->min_uV) / 2;
202 if (min_uV < thresh) {
203 val = (thresh - min_uV + info->step_uV - 1) / info->step_uV;
204 val |= 0x4;
205 } else {
206 val = (min_uV - thresh + info->step_uV - 1) / info->step_uV;
207 }
208
209 val <<= info->vol_shift;
210 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
211
212 return da903x_update(da903x_dev, info->vol_reg, val, mask);
213}
214
215static int da9030_get_ldo14_voltage(struct regulator_dev *rdev)
216{
217 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
218 struct device *da903x_dev = rdev_get_dev(rdev)->parent;
219 uint8_t val, mask;
220 int ret;
221
222 ret = da903x_read(da903x_dev, info->vol_reg, &val);
223 if (ret)
224 return ret;
225
226 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
227 val = (val & mask) >> info->vol_shift;
228
229 if (val & 0x4)
230 return info->min_uV + info->step_uV * (3 - (val & ~0x4));
231 else
232 return (info->max_uV + info->min_uV) / 2 +
233 info->step_uV * (val & ~0x4);
234}
235
236/* DA9034 specific operations */
237static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
238 int min_uV, int max_uV)
239{
240 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
241 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
242 uint8_t val, mask;
243 int ret;
244
245 if (check_range(info, min_uV, max_uV)) {
246 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV);
247 return -EINVAL;
248 }
249
250 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
251 val <<= info->vol_shift;
252 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
253
254 ret = da903x_update(da9034_dev, info->vol_reg, val, mask);
255 if (ret)
256 return ret;
257
258 ret = da903x_set_bits(da9034_dev, info->update_reg,
259 1 << info->update_bit);
260 return ret;
261}
262
263static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
264 int min_uV, int max_uV)
265{
266 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
267 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
268 uint8_t val, mask;
269
270 if (check_range(info, min_uV, max_uV)) {
271 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV);
272 return -EINVAL;
273 }
274
275 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
276 val = (val > 7 || val < 20) ? 8 : val - 12;
277 val <<= info->vol_shift;
278 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
279
280 return da903x_update(da9034_dev, info->vol_reg, val, mask);
281}
282
283static int da9034_get_ldo12_voltage(struct regulator_dev *rdev)
284{
285 struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
286 struct device *da9034_dev = rdev_get_dev(rdev)->parent;
287 uint8_t val, mask;
288 int ret;
289
290 ret = da903x_read(da9034_dev, info->vol_reg, &val);
291 if (ret)
292 return ret;
293
294 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
295 val = (val & mask) >> info->vol_shift;
296
297 if (val >= 8)
298 return 2700000 + info->step_uV * (val - 8);
299
300 return info->min_uV + info->step_uV * val;
301}
302
303static struct regulator_ops da903x_regulator_ldo_ops = {
304 .set_voltage = da903x_set_ldo_voltage,
305 .get_voltage = da903x_get_voltage,
306 .enable = da903x_enable,
307 .disable = da903x_disable,
308 .is_enabled = da903x_is_enabled,
309};
310
311/* NOTE: this is dedicated for the insane DA9030 LDO14 */
312static struct regulator_ops da9030_regulator_ldo14_ops = {
313 .set_voltage = da9030_set_ldo14_voltage,
314 .get_voltage = da9030_get_ldo14_voltage,
315 .enable = da903x_enable,
316 .disable = da903x_disable,
317 .is_enabled = da903x_is_enabled,
318};
319
320/* NOTE: this is dedicated for the DA9030 LDO1 and LDO15 that have locks */
321static struct regulator_ops da9030_regulator_ldo1_15_ops = {
322 .set_voltage = da9030_set_ldo1_15_voltage,
323 .get_voltage = da903x_get_voltage,
324 .enable = da903x_enable,
325 .disable = da903x_disable,
326 .is_enabled = da903x_is_enabled,
327};
328
329static struct regulator_ops da9034_regulator_dvc_ops = {
330 .set_voltage = da9034_set_dvc_voltage,
331 .get_voltage = da903x_get_voltage,
332 .enable = da903x_enable,
333 .disable = da903x_disable,
334 .is_enabled = da903x_is_enabled,
335};
336
337/* NOTE: this is dedicated for the insane LDO12 */
338static struct regulator_ops da9034_regulator_ldo12_ops = {
339 .set_voltage = da9034_set_ldo12_voltage,
340 .get_voltage = da9034_get_ldo12_voltage,
341 .enable = da903x_enable,
342 .disable = da903x_disable,
343 .is_enabled = da903x_is_enabled,
344};
345
346#define DA903x_LDO(_pmic, _id, min, max, step, vreg, shift, nbits, ereg, ebit) \
347{ \
348 .desc = { \
349 .name = "LDO" #_id, \
350 .ops = &da903x_regulator_ldo_ops, \
351 .type = REGULATOR_VOLTAGE, \
352 .id = _pmic##_ID_LDO##_id, \
353 .owner = THIS_MODULE, \
354 }, \
355 .min_uV = (min) * 1000, \
356 .max_uV = (max) * 1000, \
357 .step_uV = (step) * 1000, \
358 .vol_reg = _pmic##_##vreg, \
359 .vol_shift = (shift), \
360 .vol_nbits = (nbits), \
361 .enable_reg = _pmic##_##ereg, \
362 .enable_bit = (ebit), \
363}
364
365#define DA9034_DVC(_id, min, max, step, vreg, nbits, ureg, ubit, ereg, ebit) \
366{ \
367 .desc = { \
368 .name = #_id, \
369 .ops = &da9034_regulator_dvc_ops, \
370 .type = REGULATOR_VOLTAGE, \
371 .id = DA9034_ID_##_id, \
372 .owner = THIS_MODULE, \
373 }, \
374 .min_uV = (min) * 1000, \
375 .max_uV = (max) * 1000, \
376 .step_uV = (step) * 1000, \
377 .vol_reg = DA9034_##vreg, \
378 .vol_shift = (0), \
379 .vol_nbits = (nbits), \
380 .update_reg = DA9034_##ureg, \
381 .update_bit = (ubit), \
382 .enable_reg = DA9034_##ereg, \
383 .enable_bit = (ebit), \
384}
385
386#define DA9034_LDO(_id, min, max, step, vreg, shift, nbits, ereg, ebit) \
387 DA903x_LDO(DA9034, _id, min, max, step, vreg, shift, nbits, ereg, ebit)
388
389#define DA9030_LDO(_id, min, max, step, vreg, shift, nbits, ereg, ebit) \
390 DA903x_LDO(DA9030, _id, min, max, step, vreg, shift, nbits, ereg, ebit)
391
392static struct da903x_regulator_info da903x_regulator_info[] = {
393 /* DA9030 */
394 DA9030_LDO( 1, 1200, 3200, 100, LDO1, 0, 5, RCTL12, 1),
395 DA9030_LDO( 2, 1800, 3200, 100, LDO23, 0, 4, RCTL12, 2),
396 DA9030_LDO( 3, 1800, 3200, 100, LDO23, 4, 4, RCTL12, 3),
397 DA9030_LDO( 4, 1800, 3200, 100, LDO45, 0, 4, RCTL12, 4),
398 DA9030_LDO( 5, 1800, 3200, 100, LDO45, 4, 4, RCTL12, 5),
399 DA9030_LDO( 6, 1800, 3200, 100, LDO6, 0, 4, RCTL12, 6),
400 DA9030_LDO( 7, 1800, 3200, 100, LDO78, 0, 4, RCTL12, 7),
401 DA9030_LDO( 8, 1800, 3200, 100, LDO78, 4, 4, RCTL22, 0),
402 DA9030_LDO( 9, 1800, 3200, 100, LDO912, 0, 4, RCTL22, 1),
403 DA9030_LDO(10, 1800, 3200, 100, LDO1011, 0, 4, RCTL22, 2),
404 DA9030_LDO(11, 1800, 3200, 100, LDO1011, 4, 4, RCTL22, 3),
405 DA9030_LDO(12, 1800, 3200, 100, LDO912, 4, 4, RCTL22, 4),
406 DA9030_LDO(14, 2760, 2940, 30, LDO1416, 0, 3, RCTL11, 4),
407 DA9030_LDO(15, 1100, 2650, 50, LDO15, 0, 5, RCTL11, 5),
408 DA9030_LDO(16, 1100, 2650, 50, LDO1416, 3, 5, RCTL11, 6),
409 DA9030_LDO(17, 1800, 3200, 100, LDO17, 0, 4, RCTL11, 7),
410 DA9030_LDO(18, 1800, 3200, 100, LDO1819, 0, 4, RCTL21, 2),
411 DA9030_LDO(19, 1800, 3200, 100, LDO1819, 4, 4, RCTL21, 1),
412 DA9030_LDO(13, 2100, 2100, 0, INVAL, 0, 0, RCTL11, 3), /* fixed @2.1V */
413
414 /* DA9034 */
415 DA9034_DVC(BUCK1, 725, 1500, 25, ADTV1, 5, VCC1, 0, OVER1, 0),
416 DA9034_DVC(BUCK2, 725, 1500, 25, CDTV1, 5, VCC1, 2, OVER1, 1),
417 DA9034_DVC(LDO2, 725, 1500, 25, SDTV1, 5, VCC1, 4, OVER1, 2),
418 DA9034_DVC(LDO1, 1700, 2075, 25, MDTV1, 4, VCC1, 6, OVER3, 4),
419
420 DA9034_LDO( 3, 1800, 3300, 100, LDO643, 0, 4, OVER3, 5),
421 DA9034_LDO( 4, 1800, 2900,1100, LDO643, 4, 1, OVER3, 6),
422 DA9034_LDO( 6, 2500, 2850, 50, LDO643, 5, 3, OVER2, 0),
423 DA9034_LDO( 7, 2700, 3050, 50, LDO987, 0, 3, OVER2, 1),
424 DA9034_LDO( 8, 2700, 2850, 50, LDO987, 3, 2, OVER2, 2),
425 DA9034_LDO( 9, 2700, 3050, 50, LDO987, 5, 3, OVER2, 3),
426 DA9034_LDO(10, 2700, 3050, 50, LDO1110, 0, 3, OVER2, 4),
427 DA9034_LDO(11, 1800, 3300, 100, LDO1110, 4, 4, OVER2, 5),
428 DA9034_LDO(12, 1700, 3050, 50, LDO1312, 0, 4, OVER3, 6),
429 DA9034_LDO(13, 1800, 3300, 100, LDO1312, 4, 4, OVER2, 7),
430 DA9034_LDO(14, 1800, 3300, 100, LDO1514, 0, 4, OVER3, 0),
431 DA9034_LDO(15, 1800, 3300, 100, LDO1514, 4, 4, OVER3, 1),
432 DA9034_LDO(5, 3100, 3100, 0, INVAL, 0, 0, OVER3, 7), /* fixed @3.1V */
433};
434
435static inline struct da903x_regulator_info *find_regulator_info(int id)
436{
437 struct da903x_regulator_info *ri;
438 int i;
439
440 for (i = 0; i < ARRAY_SIZE(da903x_regulator_info); i++) {
441 ri = &da903x_regulator_info[i];
442 if (ri->desc.id == id)
443 return ri;
444 }
445 return NULL;
446}
447
448static int __devinit da903x_regulator_probe(struct platform_device *pdev)
449{
450 struct da903x_regulator_info *ri = NULL;
451 struct regulator_dev *rdev;
452
453 ri = find_regulator_info(pdev->id);
454 if (ri == NULL) {
455 dev_err(&pdev->dev, "invalid regulator ID specified\n");
456 return -EINVAL;
457 }
458
459 /* Workaround for the weird LDO12 voltage setting */
460 if (ri->desc.id == DA9034_ID_LDO12)
461 ri->desc.ops = &da9034_regulator_ldo12_ops;
462
463 if (ri->desc.id == DA9030_ID_LDO14)
464 ri->desc.ops = &da9030_regulator_ldo14_ops;
465
466 if (ri->desc.id == DA9030_ID_LDO1 || ri->desc.id == DA9030_ID_LDO15)
467 ri->desc.ops = &da9030_regulator_ldo1_15_ops;
468
469 rdev = regulator_register(&ri->desc, pdev->dev.parent, ri);
470 if (IS_ERR(rdev)) {
471 dev_err(&pdev->dev, "failed to register regulator %s\n",
472 ri->desc.name);
473 return PTR_ERR(rdev);
474 }
475
476 platform_set_drvdata(pdev, rdev);
477 return 0;
478}
479
480static int __devexit da903x_regulator_remove(struct platform_device *pdev)
481{
482 struct regulator_dev *rdev = platform_get_drvdata(pdev);
483
484 regulator_unregister(rdev);
485 return 0;
486}
487
488static struct platform_driver da903x_regulator_driver = {
489 .driver = {
490 .name = "da903x-regulator",
491 .owner = THIS_MODULE,
492 },
493 .probe = da903x_regulator_probe,
494 .remove = da903x_regulator_remove,
495};
496
497static int __init da903x_regulator_init(void)
498{
499 return platform_driver_register(&da903x_regulator_driver);
500}
501module_init(da903x_regulator_init);
502
503static void __exit da903x_regulator_exit(void)
504{
505 platform_driver_unregister(&da903x_regulator_driver);
506}
507module_exit(da903x_regulator_exit);
508
509MODULE_LICENSE("GPL");
510MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"
511 "Mike Rapoport <mike@compulab.co.il>");
512MODULE_DESCRIPTION("Regulator Driver for Dialog Semiconductor DA903X PMIC");
513MODULE_ALIAS("platform:da903x-regulator");
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
new file mode 100644
index 000000000000..1f44b17e23b1
--- /dev/null
+++ b/drivers/regulator/wm8350-regulator.c
@@ -0,0 +1,1431 @@
1/*
2 * wm8350.c -- Voltage and current regulation for the Wolfson WM8350 PMIC
3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood
7 * linux@wolfsonmicro.com
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
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/init.h>
18#include <linux/bitops.h>
19#include <linux/err.h>
20#include <linux/i2c.h>
21#include <linux/mfd/wm8350/core.h>
22#include <linux/mfd/wm8350/pmic.h>
23#include <linux/platform_device.h>
24#include <linux/regulator/driver.h>
25#include <linux/regulator/machine.h>
26
27/* Microamps */
28static const int isink_cur[] = {
29 4,
30 5,
31 6,
32 7,
33 8,
34 10,
35 11,
36 14,
37 16,
38 19,
39 23,
40 27,
41 32,
42 39,
43 46,
44 54,
45 65,
46 77,
47 92,
48 109,
49 130,
50 154,
51 183,
52 218,
53 259,
54 308,
55 367,
56 436,
57 518,
58 616,
59 733,
60 872,
61 1037,
62 1233,
63 1466,
64 1744,
65 2073,
66 2466,
67 2933,
68 3487,
69 4147,
70 4932,
71 5865,
72 6975,
73 8294,
74 9864,
75 11730,
76 13949,
77 16589,
78 19728,
79 23460,
80 27899,
81 33178,
82 39455,
83 46920,
84 55798,
85 66355,
86 78910,
87 93840,
88 111596,
89 132710,
90 157820,
91 187681,
92 223191
93};
94
95static int get_isink_val(int min_uA, int max_uA, u16 *setting)
96{
97 int i;
98
99 for (i = ARRAY_SIZE(isink_cur) - 1; i >= 0; i--) {
100 if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) {
101 *setting = i;
102 return 0;
103 }
104 }
105 return -EINVAL;
106}
107
108static inline int wm8350_ldo_val_to_mvolts(unsigned int val)
109{
110 if (val < 16)
111 return (val * 50) + 900;
112 else
113 return ((val - 16) * 100) + 1800;
114
115}
116
117static inline unsigned int wm8350_ldo_mvolts_to_val(int mV)
118{
119 if (mV < 1800)
120 return (mV - 900) / 50;
121 else
122 return ((mV - 1800) / 100) + 16;
123}
124
125static inline int wm8350_dcdc_val_to_mvolts(unsigned int val)
126{
127 return (val * 25) + 850;
128}
129
130static inline unsigned int wm8350_dcdc_mvolts_to_val(int mV)
131{
132 return (mV - 850) / 25;
133}
134
135static int wm8350_isink_set_current(struct regulator_dev *rdev, int min_uA,
136 int max_uA)
137{
138 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
139 int isink = rdev_get_id(rdev);
140 u16 val, setting;
141 int ret;
142
143 ret = get_isink_val(min_uA, max_uA, &setting);
144 if (ret != 0)
145 return ret;
146
147 switch (isink) {
148 case WM8350_ISINK_A:
149 val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_A) &
150 ~WM8350_CS1_ISEL_MASK;
151 wm8350_reg_write(wm8350, WM8350_CURRENT_SINK_DRIVER_A,
152 val | setting);
153 break;
154 case WM8350_ISINK_B:
155 val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_B) &
156 ~WM8350_CS1_ISEL_MASK;
157 wm8350_reg_write(wm8350, WM8350_CURRENT_SINK_DRIVER_B,
158 val | setting);
159 break;
160 default:
161 return -EINVAL;
162 }
163
164 return 0;
165}
166
167static int wm8350_isink_get_current(struct regulator_dev *rdev)
168{
169 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
170 int isink = rdev_get_id(rdev);
171 u16 val;
172
173 switch (isink) {
174 case WM8350_ISINK_A:
175 val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_A) &
176 WM8350_CS1_ISEL_MASK;
177 break;
178 case WM8350_ISINK_B:
179 val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_B) &
180 WM8350_CS1_ISEL_MASK;
181 break;
182 default:
183 return 0;
184 }
185
186 return (isink_cur[val] + 50) / 100;
187}
188
189/* turn on ISINK followed by DCDC */
190static int wm8350_isink_enable(struct regulator_dev *rdev)
191{
192 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
193 int isink = rdev_get_id(rdev);
194
195 switch (isink) {
196 case WM8350_ISINK_A:
197 switch (wm8350->pmic.isink_A_dcdc) {
198 case WM8350_DCDC_2:
199 case WM8350_DCDC_5:
200 wm8350_set_bits(wm8350, WM8350_POWER_MGMT_7,
201 WM8350_CS1_ENA);
202 wm8350_set_bits(wm8350, WM8350_CSA_FLASH_CONTROL,
203 WM8350_CS1_DRIVE);
204 wm8350_set_bits(wm8350, WM8350_DCDC_LDO_REQUESTED,
205 1 << (wm8350->pmic.isink_A_dcdc -
206 WM8350_DCDC_1));
207 break;
208 default:
209 return -EINVAL;
210 }
211 break;
212 case WM8350_ISINK_B:
213 switch (wm8350->pmic.isink_B_dcdc) {
214 case WM8350_DCDC_2:
215 case WM8350_DCDC_5:
216 wm8350_set_bits(wm8350, WM8350_POWER_MGMT_7,
217 WM8350_CS2_ENA);
218 wm8350_set_bits(wm8350, WM8350_CSB_FLASH_CONTROL,
219 WM8350_CS2_DRIVE);
220 wm8350_set_bits(wm8350, WM8350_DCDC_LDO_REQUESTED,
221 1 << (wm8350->pmic.isink_B_dcdc -
222 WM8350_DCDC_1));
223 break;
224 default:
225 return -EINVAL;
226 }
227 break;
228 default:
229 return -EINVAL;
230 }
231 return 0;
232}
233
234static int wm8350_isink_disable(struct regulator_dev *rdev)
235{
236 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
237 int isink = rdev_get_id(rdev);
238
239 switch (isink) {
240 case WM8350_ISINK_A:
241 switch (wm8350->pmic.isink_A_dcdc) {
242 case WM8350_DCDC_2:
243 case WM8350_DCDC_5:
244 wm8350_clear_bits(wm8350, WM8350_DCDC_LDO_REQUESTED,
245 1 << (wm8350->pmic.isink_A_dcdc -
246 WM8350_DCDC_1));
247 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_7,
248 WM8350_CS1_ENA);
249 break;
250 default:
251 return -EINVAL;
252 }
253 break;
254 case WM8350_ISINK_B:
255 switch (wm8350->pmic.isink_B_dcdc) {
256 case WM8350_DCDC_2:
257 case WM8350_DCDC_5:
258 wm8350_clear_bits(wm8350, WM8350_DCDC_LDO_REQUESTED,
259 1 << (wm8350->pmic.isink_B_dcdc -
260 WM8350_DCDC_1));
261 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_7,
262 WM8350_CS2_ENA);
263 break;
264 default:
265 return -EINVAL;
266 }
267 break;
268 default:
269 return -EINVAL;
270 }
271 return 0;
272}
273
274static int wm8350_isink_is_enabled(struct regulator_dev *rdev)
275{
276 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
277 int isink = rdev_get_id(rdev);
278
279 switch (isink) {
280 case WM8350_ISINK_A:
281 return wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_A) &
282 0x8000;
283 case WM8350_ISINK_B:
284 return wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_B) &
285 0x8000;
286 }
287 return -EINVAL;
288}
289
290int wm8350_isink_set_flash(struct wm8350 *wm8350, int isink, u16 mode,
291 u16 trigger, u16 duration, u16 on_ramp, u16 off_ramp,
292 u16 drive)
293{
294 switch (isink) {
295 case WM8350_ISINK_A:
296 wm8350_reg_write(wm8350, WM8350_CSA_FLASH_CONTROL,
297 (mode ? WM8350_CS1_FLASH_MODE : 0) |
298 (trigger ? WM8350_CS1_TRIGSRC : 0) |
299 duration | on_ramp | off_ramp | drive);
300 break;
301 case WM8350_ISINK_B:
302 wm8350_reg_write(wm8350, WM8350_CSB_FLASH_CONTROL,
303 (mode ? WM8350_CS2_FLASH_MODE : 0) |
304 (trigger ? WM8350_CS2_TRIGSRC : 0) |
305 duration | on_ramp | off_ramp | drive);
306 break;
307 default:
308 return -EINVAL;
309 }
310 return 0;
311}
312EXPORT_SYMBOL_GPL(wm8350_isink_set_flash);
313
314static int wm8350_dcdc_set_voltage(struct regulator_dev *rdev, int min_uV,
315 int max_uV)
316{
317 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
318 int volt_reg, dcdc = rdev_get_id(rdev), mV,
319 min_mV = min_uV / 1000, max_mV = max_uV / 1000;
320 u16 val;
321
322 if (min_mV < 850 || min_mV > 4025)
323 return -EINVAL;
324 if (max_mV < 850 || max_mV > 4025)
325 return -EINVAL;
326
327 /* step size is 25mV */
328 mV = (min_mV - 826) / 25;
329 if (wm8350_dcdc_val_to_mvolts(mV) > max_mV)
330 return -EINVAL;
331 BUG_ON(wm8350_dcdc_val_to_mvolts(mV) < min_mV);
332
333 switch (dcdc) {
334 case WM8350_DCDC_1:
335 volt_reg = WM8350_DCDC1_CONTROL;
336 break;
337 case WM8350_DCDC_3:
338 volt_reg = WM8350_DCDC3_CONTROL;
339 break;
340 case WM8350_DCDC_4:
341 volt_reg = WM8350_DCDC4_CONTROL;
342 break;
343 case WM8350_DCDC_6:
344 volt_reg = WM8350_DCDC6_CONTROL;
345 break;
346 case WM8350_DCDC_2:
347 case WM8350_DCDC_5:
348 default:
349 return -EINVAL;
350 }
351
352 /* all DCDCs have same mV bits */
353 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_DC1_VSEL_MASK;
354 wm8350_reg_write(wm8350, volt_reg, val | mV);
355 return 0;
356}
357
358static int wm8350_dcdc_get_voltage(struct regulator_dev *rdev)
359{
360 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
361 int volt_reg, dcdc = rdev_get_id(rdev);
362 u16 val;
363
364 switch (dcdc) {
365 case WM8350_DCDC_1:
366 volt_reg = WM8350_DCDC1_CONTROL;
367 break;
368 case WM8350_DCDC_3:
369 volt_reg = WM8350_DCDC3_CONTROL;
370 break;
371 case WM8350_DCDC_4:
372 volt_reg = WM8350_DCDC4_CONTROL;
373 break;
374 case WM8350_DCDC_6:
375 volt_reg = WM8350_DCDC6_CONTROL;
376 break;
377 case WM8350_DCDC_2:
378 case WM8350_DCDC_5:
379 default:
380 return -EINVAL;
381 }
382
383 /* all DCDCs have same mV bits */
384 val = wm8350_reg_read(wm8350, volt_reg) & WM8350_DC1_VSEL_MASK;
385 return wm8350_dcdc_val_to_mvolts(val) * 1000;
386}
387
388static int wm8350_dcdc_set_suspend_voltage(struct regulator_dev *rdev, int uV)
389{
390 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
391 int volt_reg, mV = uV / 1000, dcdc = rdev_get_id(rdev);
392 u16 val;
393
394 dev_dbg(wm8350->dev, "%s %d mV %d\n", __func__, dcdc, mV);
395
396 if (mV && (mV < 850 || mV > 4025)) {
397 dev_err(wm8350->dev,
398 "DCDC%d suspend voltage %d mV out of range\n",
399 dcdc, mV);
400 return -EINVAL;
401 }
402 if (mV == 0)
403 mV = 850;
404
405 switch (dcdc) {
406 case WM8350_DCDC_1:
407 volt_reg = WM8350_DCDC1_LOW_POWER;
408 break;
409 case WM8350_DCDC_3:
410 volt_reg = WM8350_DCDC3_LOW_POWER;
411 break;
412 case WM8350_DCDC_4:
413 volt_reg = WM8350_DCDC4_LOW_POWER;
414 break;
415 case WM8350_DCDC_6:
416 volt_reg = WM8350_DCDC6_LOW_POWER;
417 break;
418 case WM8350_DCDC_2:
419 case WM8350_DCDC_5:
420 default:
421 return -EINVAL;
422 }
423
424 /* all DCDCs have same mV bits */
425 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_DC1_VSEL_MASK;
426 wm8350_reg_write(wm8350, volt_reg,
427 val | wm8350_dcdc_mvolts_to_val(mV));
428 return 0;
429}
430
431static int wm8350_dcdc_set_suspend_enable(struct regulator_dev *rdev)
432{
433 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
434 int dcdc = rdev_get_id(rdev);
435 u16 val;
436
437 switch (dcdc) {
438 case WM8350_DCDC_1:
439 val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER)
440 & ~WM8350_DCDC_HIB_MODE_MASK;
441 wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER,
442 wm8350->pmic.dcdc1_hib_mode);
443 break;
444 case WM8350_DCDC_3:
445 val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER)
446 & ~WM8350_DCDC_HIB_MODE_MASK;
447 wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER,
448 wm8350->pmic.dcdc3_hib_mode);
449 break;
450 case WM8350_DCDC_4:
451 val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER)
452 & ~WM8350_DCDC_HIB_MODE_MASK;
453 wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER,
454 wm8350->pmic.dcdc4_hib_mode);
455 break;
456 case WM8350_DCDC_6:
457 val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER)
458 & ~WM8350_DCDC_HIB_MODE_MASK;
459 wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER,
460 wm8350->pmic.dcdc6_hib_mode);
461 break;
462 case WM8350_DCDC_2:
463 case WM8350_DCDC_5:
464 default:
465 return -EINVAL;
466 }
467
468 return 0;
469}
470
471static int wm8350_dcdc_set_suspend_disable(struct regulator_dev *rdev)
472{
473 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
474 int dcdc = rdev_get_id(rdev);
475 u16 val;
476
477 switch (dcdc) {
478 case WM8350_DCDC_1:
479 val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER);
480 wm8350->pmic.dcdc1_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
481 wm8350_reg_write(wm8350, WM8350_DCDC1_LOW_POWER,
482 WM8350_DCDC_HIB_MODE_DIS);
483 break;
484 case WM8350_DCDC_3:
485 val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER);
486 wm8350->pmic.dcdc3_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
487 wm8350_reg_write(wm8350, WM8350_DCDC3_LOW_POWER,
488 WM8350_DCDC_HIB_MODE_DIS);
489 break;
490 case WM8350_DCDC_4:
491 val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER);
492 wm8350->pmic.dcdc4_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
493 wm8350_reg_write(wm8350, WM8350_DCDC4_LOW_POWER,
494 WM8350_DCDC_HIB_MODE_DIS);
495 break;
496 case WM8350_DCDC_6:
497 val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER);
498 wm8350->pmic.dcdc6_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
499 wm8350_reg_write(wm8350, WM8350_DCDC6_LOW_POWER,
500 WM8350_DCDC_HIB_MODE_DIS);
501 break;
502 case WM8350_DCDC_2:
503 case WM8350_DCDC_5:
504 default:
505 return -EINVAL;
506 }
507
508 return 0;
509}
510
511static int wm8350_dcdc25_set_suspend_enable(struct regulator_dev *rdev)
512{
513 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
514 int dcdc = rdev_get_id(rdev);
515 u16 val;
516
517 switch (dcdc) {
518 case WM8350_DCDC_2:
519 val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL)
520 & ~WM8350_DC2_HIB_MODE_MASK;
521 wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val |
522 WM8350_DC2_HIB_MODE_ACTIVE);
523 break;
524 case WM8350_DCDC_5:
525 val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL)
526 & ~WM8350_DC2_HIB_MODE_MASK;
527 wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val |
528 WM8350_DC5_HIB_MODE_ACTIVE);
529 break;
530 default:
531 return -EINVAL;
532 }
533 return 0;
534}
535
536static int wm8350_dcdc25_set_suspend_disable(struct regulator_dev *rdev)
537{
538 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
539 int dcdc = rdev_get_id(rdev);
540 u16 val;
541
542 switch (dcdc) {
543 case WM8350_DCDC_2:
544 val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL)
545 & ~WM8350_DC2_HIB_MODE_MASK;
546 wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val |
547 WM8350_DC2_HIB_MODE_DISABLE);
548 break;
549 case WM8350_DCDC_5:
550 val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL)
551 & ~WM8350_DC2_HIB_MODE_MASK;
552 wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val |
553 WM8350_DC2_HIB_MODE_DISABLE);
554 break;
555 default:
556 return -EINVAL;
557 }
558 return 0;
559}
560
561static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev,
562 unsigned int mode)
563{
564 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
565 int dcdc = rdev_get_id(rdev);
566 u16 *hib_mode;
567
568 switch (dcdc) {
569 case WM8350_DCDC_1:
570 hib_mode = &wm8350->pmic.dcdc1_hib_mode;
571 break;
572 case WM8350_DCDC_3:
573 hib_mode = &wm8350->pmic.dcdc3_hib_mode;
574 break;
575 case WM8350_DCDC_4:
576 hib_mode = &wm8350->pmic.dcdc4_hib_mode;
577 break;
578 case WM8350_DCDC_6:
579 hib_mode = &wm8350->pmic.dcdc6_hib_mode;
580 break;
581 case WM8350_DCDC_2:
582 case WM8350_DCDC_5:
583 default:
584 return -EINVAL;
585 }
586
587 switch (mode) {
588 case REGULATOR_MODE_NORMAL:
589 *hib_mode = WM8350_DCDC_HIB_MODE_IMAGE;
590 break;
591 case REGULATOR_MODE_IDLE:
592 *hib_mode = WM8350_DCDC_HIB_MODE_STANDBY;
593 break;
594 case REGULATOR_MODE_STANDBY:
595 *hib_mode = WM8350_DCDC_HIB_MODE_LDO_IM;
596 break;
597 default:
598 return -EINVAL;
599 }
600
601 return 0;
602}
603
604static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV)
605{
606 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
607 int volt_reg, mV = uV / 1000, ldo = rdev_get_id(rdev);
608 u16 val;
609
610 dev_dbg(wm8350->dev, "%s %d mV %d\n", __func__, ldo, mV);
611
612 if (mV < 900 || mV > 3300) {
613 dev_err(wm8350->dev, "LDO%d voltage %d mV out of range\n",
614 ldo, mV);
615 return -EINVAL;
616 }
617
618 switch (ldo) {
619 case WM8350_LDO_1:
620 volt_reg = WM8350_LDO1_LOW_POWER;
621 break;
622 case WM8350_LDO_2:
623 volt_reg = WM8350_LDO2_LOW_POWER;
624 break;
625 case WM8350_LDO_3:
626 volt_reg = WM8350_LDO3_LOW_POWER;
627 break;
628 case WM8350_LDO_4:
629 volt_reg = WM8350_LDO4_LOW_POWER;
630 break;
631 default:
632 return -EINVAL;
633 }
634
635 /* all LDOs have same mV bits */
636 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_VSEL_MASK;
637 wm8350_reg_write(wm8350, volt_reg,
638 val | wm8350_ldo_mvolts_to_val(mV));
639 return 0;
640}
641
642static int wm8350_ldo_set_suspend_enable(struct regulator_dev *rdev)
643{
644 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
645 int volt_reg, ldo = rdev_get_id(rdev);
646 u16 val;
647
648 switch (ldo) {
649 case WM8350_LDO_1:
650 volt_reg = WM8350_LDO1_LOW_POWER;
651 break;
652 case WM8350_LDO_2:
653 volt_reg = WM8350_LDO2_LOW_POWER;
654 break;
655 case WM8350_LDO_3:
656 volt_reg = WM8350_LDO3_LOW_POWER;
657 break;
658 case WM8350_LDO_4:
659 volt_reg = WM8350_LDO4_LOW_POWER;
660 break;
661 default:
662 return -EINVAL;
663 }
664
665 /* all LDOs have same mV bits */
666 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_HIB_MODE_MASK;
667 wm8350_reg_write(wm8350, volt_reg, val);
668 return 0;
669}
670
671static int wm8350_ldo_set_suspend_disable(struct regulator_dev *rdev)
672{
673 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
674 int volt_reg, ldo = rdev_get_id(rdev);
675 u16 val;
676
677 switch (ldo) {
678 case WM8350_LDO_1:
679 volt_reg = WM8350_LDO1_LOW_POWER;
680 break;
681 case WM8350_LDO_2:
682 volt_reg = WM8350_LDO2_LOW_POWER;
683 break;
684 case WM8350_LDO_3:
685 volt_reg = WM8350_LDO3_LOW_POWER;
686 break;
687 case WM8350_LDO_4:
688 volt_reg = WM8350_LDO4_LOW_POWER;
689 break;
690 default:
691 return -EINVAL;
692 }
693
694 /* all LDOs have same mV bits */
695 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_HIB_MODE_MASK;
696 wm8350_reg_write(wm8350, volt_reg, WM8350_LDO1_HIB_MODE_DIS);
697 return 0;
698}
699
700static int wm8350_ldo_set_voltage(struct regulator_dev *rdev, int min_uV,
701 int max_uV)
702{
703 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
704 int volt_reg, ldo = rdev_get_id(rdev), mV, min_mV = min_uV / 1000,
705 max_mV = max_uV / 1000;
706 u16 val;
707
708 if (min_mV < 900 || min_mV > 3300)
709 return -EINVAL;
710 if (max_mV < 900 || max_mV > 3300)
711 return -EINVAL;
712
713 if (min_mV < 1800) {
714 /* step size is 50mV < 1800mV */
715 mV = (min_mV - 851) / 50;
716 if (wm8350_ldo_val_to_mvolts(mV) > max_mV)
717 return -EINVAL;
718 BUG_ON(wm8350_ldo_val_to_mvolts(mV) < min_mV);
719 } else {
720 /* step size is 100mV > 1800mV */
721 mV = ((min_mV - 1701) / 100) + 16;
722 if (wm8350_ldo_val_to_mvolts(mV) > max_mV)
723 return -EINVAL;
724 BUG_ON(wm8350_ldo_val_to_mvolts(mV) < min_mV);
725 }
726
727 switch (ldo) {
728 case WM8350_LDO_1:
729 volt_reg = WM8350_LDO1_CONTROL;
730 break;
731 case WM8350_LDO_2:
732 volt_reg = WM8350_LDO2_CONTROL;
733 break;
734 case WM8350_LDO_3:
735 volt_reg = WM8350_LDO3_CONTROL;
736 break;
737 case WM8350_LDO_4:
738 volt_reg = WM8350_LDO4_CONTROL;
739 break;
740 default:
741 return -EINVAL;
742 }
743
744 /* all LDOs have same mV bits */
745 val = wm8350_reg_read(wm8350, volt_reg) & ~WM8350_LDO1_VSEL_MASK;
746 wm8350_reg_write(wm8350, volt_reg, val | mV);
747 return 0;
748}
749
750static int wm8350_ldo_get_voltage(struct regulator_dev *rdev)
751{
752 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
753 int volt_reg, ldo = rdev_get_id(rdev);
754 u16 val;
755
756 switch (ldo) {
757 case WM8350_LDO_1:
758 volt_reg = WM8350_LDO1_CONTROL;
759 break;
760 case WM8350_LDO_2:
761 volt_reg = WM8350_LDO2_CONTROL;
762 break;
763 case WM8350_LDO_3:
764 volt_reg = WM8350_LDO3_CONTROL;
765 break;
766 case WM8350_LDO_4:
767 volt_reg = WM8350_LDO4_CONTROL;
768 break;
769 default:
770 return -EINVAL;
771 }
772
773 /* all LDOs have same mV bits */
774 val = wm8350_reg_read(wm8350, volt_reg) & WM8350_LDO1_VSEL_MASK;
775 return wm8350_ldo_val_to_mvolts(val) * 1000;
776}
777
778int wm8350_dcdc_set_slot(struct wm8350 *wm8350, int dcdc, u16 start,
779 u16 stop, u16 fault)
780{
781 int slot_reg;
782 u16 val;
783
784 dev_dbg(wm8350->dev, "%s %d start %d stop %d\n",
785 __func__, dcdc, start, stop);
786
787 /* slot valid ? */
788 if (start > 15 || stop > 15)
789 return -EINVAL;
790
791 switch (dcdc) {
792 case WM8350_DCDC_1:
793 slot_reg = WM8350_DCDC1_TIMEOUTS;
794 break;
795 case WM8350_DCDC_2:
796 slot_reg = WM8350_DCDC2_TIMEOUTS;
797 break;
798 case WM8350_DCDC_3:
799 slot_reg = WM8350_DCDC3_TIMEOUTS;
800 break;
801 case WM8350_DCDC_4:
802 slot_reg = WM8350_DCDC4_TIMEOUTS;
803 break;
804 case WM8350_DCDC_5:
805 slot_reg = WM8350_DCDC5_TIMEOUTS;
806 break;
807 case WM8350_DCDC_6:
808 slot_reg = WM8350_DCDC6_TIMEOUTS;
809 break;
810 default:
811 return -EINVAL;
812 }
813
814 val = wm8350_reg_read(wm8350, slot_reg) &
815 ~(WM8350_DC1_ENSLOT_MASK | WM8350_DC1_SDSLOT_MASK |
816 WM8350_DC1_ERRACT_MASK);
817 wm8350_reg_write(wm8350, slot_reg,
818 val | (start << WM8350_DC1_ENSLOT_SHIFT) |
819 (stop << WM8350_DC1_SDSLOT_SHIFT) |
820 (fault << WM8350_DC1_ERRACT_SHIFT));
821
822 return 0;
823}
824EXPORT_SYMBOL_GPL(wm8350_dcdc_set_slot);
825
826int wm8350_ldo_set_slot(struct wm8350 *wm8350, int ldo, u16 start, u16 stop)
827{
828 int slot_reg;
829 u16 val;
830
831 dev_dbg(wm8350->dev, "%s %d start %d stop %d\n",
832 __func__, ldo, start, stop);
833
834 /* slot valid ? */
835 if (start > 15 || stop > 15)
836 return -EINVAL;
837
838 switch (ldo) {
839 case WM8350_LDO_1:
840 slot_reg = WM8350_LDO1_TIMEOUTS;
841 break;
842 case WM8350_LDO_2:
843 slot_reg = WM8350_LDO2_TIMEOUTS;
844 break;
845 case WM8350_LDO_3:
846 slot_reg = WM8350_LDO3_TIMEOUTS;
847 break;
848 case WM8350_LDO_4:
849 slot_reg = WM8350_LDO4_TIMEOUTS;
850 break;
851 default:
852 return -EINVAL;
853 }
854
855 val = wm8350_reg_read(wm8350, slot_reg) & ~WM8350_LDO1_SDSLOT_MASK;
856 wm8350_reg_write(wm8350, slot_reg, val | ((start << 10) | (stop << 6)));
857 return 0;
858}
859EXPORT_SYMBOL_GPL(wm8350_ldo_set_slot);
860
861int wm8350_dcdc25_set_mode(struct wm8350 *wm8350, int dcdc, u16 mode,
862 u16 ilim, u16 ramp, u16 feedback)
863{
864 u16 val;
865
866 dev_dbg(wm8350->dev, "%s %d mode: %s %s\n", __func__, dcdc,
867 mode ? "normal" : "boost", ilim ? "low" : "normal");
868
869 switch (dcdc) {
870 case WM8350_DCDC_2:
871 val = wm8350_reg_read(wm8350, WM8350_DCDC2_CONTROL)
872 & ~(WM8350_DC2_MODE_MASK | WM8350_DC2_ILIM_MASK |
873 WM8350_DC2_RMP_MASK | WM8350_DC2_FBSRC_MASK);
874 wm8350_reg_write(wm8350, WM8350_DCDC2_CONTROL, val |
875 (mode << WM8350_DC2_MODE_SHIFT) |
876 (ilim << WM8350_DC2_ILIM_SHIFT) |
877 (ramp << WM8350_DC2_RMP_SHIFT) |
878 (feedback << WM8350_DC2_FBSRC_SHIFT));
879 break;
880 case WM8350_DCDC_5:
881 val = wm8350_reg_read(wm8350, WM8350_DCDC5_CONTROL)
882 & ~(WM8350_DC5_MODE_MASK | WM8350_DC5_ILIM_MASK |
883 WM8350_DC5_RMP_MASK | WM8350_DC5_FBSRC_MASK);
884 wm8350_reg_write(wm8350, WM8350_DCDC5_CONTROL, val |
885 (mode << WM8350_DC5_MODE_SHIFT) |
886 (ilim << WM8350_DC5_ILIM_SHIFT) |
887 (ramp << WM8350_DC5_RMP_SHIFT) |
888 (feedback << WM8350_DC5_FBSRC_SHIFT));
889 break;
890 default:
891 return -EINVAL;
892 }
893
894 return 0;
895}
896EXPORT_SYMBOL_GPL(wm8350_dcdc25_set_mode);
897
898static int wm8350_dcdc_enable(struct regulator_dev *rdev)
899{
900 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
901 int dcdc = rdev_get_id(rdev);
902 u16 shift;
903
904 if (dcdc < WM8350_DCDC_1 || dcdc > WM8350_DCDC_6)
905 return -EINVAL;
906
907 shift = dcdc - WM8350_DCDC_1;
908 wm8350_set_bits(wm8350, WM8350_DCDC_LDO_REQUESTED, 1 << shift);
909 return 0;
910}
911
912static int wm8350_dcdc_disable(struct regulator_dev *rdev)
913{
914 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
915 int dcdc = rdev_get_id(rdev);
916 u16 shift;
917
918 if (dcdc < WM8350_DCDC_1 || dcdc > WM8350_DCDC_6)
919 return -EINVAL;
920
921 shift = dcdc - WM8350_DCDC_1;
922 wm8350_clear_bits(wm8350, WM8350_DCDC_LDO_REQUESTED, 1 << shift);
923
924 return 0;
925}
926
927static int wm8350_ldo_enable(struct regulator_dev *rdev)
928{
929 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
930 int ldo = rdev_get_id(rdev);
931 u16 shift;
932
933 if (ldo < WM8350_LDO_1 || ldo > WM8350_LDO_4)
934 return -EINVAL;
935
936 shift = (ldo - WM8350_LDO_1) + 8;
937 wm8350_set_bits(wm8350, WM8350_DCDC_LDO_REQUESTED, 1 << shift);
938 return 0;
939}
940
941static int wm8350_ldo_disable(struct regulator_dev *rdev)
942{
943 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
944 int ldo = rdev_get_id(rdev);
945 u16 shift;
946
947 if (ldo < WM8350_LDO_1 || ldo > WM8350_LDO_4)
948 return -EINVAL;
949
950 shift = (ldo - WM8350_LDO_1) + 8;
951 wm8350_clear_bits(wm8350, WM8350_DCDC_LDO_REQUESTED, 1 << shift);
952 return 0;
953}
954
955static int force_continuous_enable(struct wm8350 *wm8350, int dcdc, int enable)
956{
957 int reg = 0, ret;
958
959 switch (dcdc) {
960 case WM8350_DCDC_1:
961 reg = WM8350_DCDC1_FORCE_PWM;
962 break;
963 case WM8350_DCDC_3:
964 reg = WM8350_DCDC3_FORCE_PWM;
965 break;
966 case WM8350_DCDC_4:
967 reg = WM8350_DCDC4_FORCE_PWM;
968 break;
969 case WM8350_DCDC_6:
970 reg = WM8350_DCDC6_FORCE_PWM;
971 break;
972 default:
973 return -EINVAL;
974 }
975
976 if (enable)
977 ret = wm8350_set_bits(wm8350, reg,
978 WM8350_DCDC1_FORCE_PWM_ENA);
979 else
980 ret = wm8350_clear_bits(wm8350, reg,
981 WM8350_DCDC1_FORCE_PWM_ENA);
982 return ret;
983}
984
985static int wm8350_dcdc_set_mode(struct regulator_dev *rdev, unsigned int mode)
986{
987 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
988 int dcdc = rdev_get_id(rdev);
989 u16 val;
990
991 if (dcdc < WM8350_DCDC_1 || dcdc > WM8350_DCDC_6)
992 return -EINVAL;
993
994 if (dcdc == WM8350_DCDC_2 || dcdc == WM8350_DCDC_5)
995 return -EINVAL;
996
997 val = 1 << (dcdc - WM8350_DCDC_1);
998
999 switch (mode) {
1000 case REGULATOR_MODE_FAST:
1001 /* force continuous mode */
1002 wm8350_set_bits(wm8350, WM8350_DCDC_ACTIVE_OPTIONS, val);
1003 wm8350_clear_bits(wm8350, WM8350_DCDC_SLEEP_OPTIONS, val);
1004 force_continuous_enable(wm8350, dcdc, 1);
1005 break;
1006 case REGULATOR_MODE_NORMAL:
1007 /* active / pulse skipping */
1008 wm8350_set_bits(wm8350, WM8350_DCDC_ACTIVE_OPTIONS, val);
1009 wm8350_clear_bits(wm8350, WM8350_DCDC_SLEEP_OPTIONS, val);
1010 force_continuous_enable(wm8350, dcdc, 0);
1011 break;
1012 case REGULATOR_MODE_IDLE:
1013 /* standby mode */
1014 force_continuous_enable(wm8350, dcdc, 0);
1015 wm8350_clear_bits(wm8350, WM8350_DCDC_SLEEP_OPTIONS, val);
1016 wm8350_clear_bits(wm8350, WM8350_DCDC_ACTIVE_OPTIONS, val);
1017 break;
1018 case REGULATOR_MODE_STANDBY:
1019 /* LDO mode */
1020 force_continuous_enable(wm8350, dcdc, 0);
1021 wm8350_set_bits(wm8350, WM8350_DCDC_SLEEP_OPTIONS, val);
1022 break;
1023 }
1024
1025 return 0;
1026}
1027
1028static unsigned int wm8350_dcdc_get_mode(struct regulator_dev *rdev)
1029{
1030 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
1031 int dcdc = rdev_get_id(rdev);
1032 u16 mask, sleep, active, force;
1033 int mode = REGULATOR_MODE_NORMAL;
1034
1035 if (dcdc < WM8350_DCDC_1 || dcdc > WM8350_DCDC_6)
1036 return -EINVAL;
1037
1038 if (dcdc == WM8350_DCDC_2 || dcdc == WM8350_DCDC_5)
1039 return -EINVAL;
1040
1041 mask = 1 << (dcdc - WM8350_DCDC_1);
1042 active = wm8350_reg_read(wm8350, WM8350_DCDC_ACTIVE_OPTIONS) & mask;
1043 sleep = wm8350_reg_read(wm8350, WM8350_DCDC_SLEEP_OPTIONS) & mask;
1044 force = wm8350_reg_read(wm8350, WM8350_DCDC1_FORCE_PWM)
1045 & WM8350_DCDC1_FORCE_PWM_ENA;
1046 dev_dbg(wm8350->dev, "mask %x active %x sleep %x force %x",
1047 mask, active, sleep, force);
1048
1049 if (active && !sleep) {
1050 if (force)
1051 mode = REGULATOR_MODE_FAST;
1052 else
1053 mode = REGULATOR_MODE_NORMAL;
1054 } else if (!active && !sleep)
1055 mode = REGULATOR_MODE_IDLE;
1056 else if (!sleep)
1057 mode = REGULATOR_MODE_STANDBY;
1058
1059 return mode;
1060}
1061
1062static unsigned int wm8350_ldo_get_mode(struct regulator_dev *rdev)
1063{
1064 return REGULATOR_MODE_NORMAL;
1065}
1066
1067struct wm8350_dcdc_efficiency {
1068 int uA_load_min;
1069 int uA_load_max;
1070 unsigned int mode;
1071};
1072
1073static const struct wm8350_dcdc_efficiency dcdc1_6_efficiency[] = {
1074 {0, 10000, REGULATOR_MODE_STANDBY}, /* 0 - 10mA - LDO */
1075 {10000, 100000, REGULATOR_MODE_IDLE}, /* 10mA - 100mA - Standby */
1076 {100000, 1000000, REGULATOR_MODE_NORMAL}, /* > 100mA - Active */
1077 {-1, -1, REGULATOR_MODE_NORMAL},
1078};
1079
1080static const struct wm8350_dcdc_efficiency dcdc3_4_efficiency[] = {
1081 {0, 10000, REGULATOR_MODE_STANDBY}, /* 0 - 10mA - LDO */
1082 {10000, 100000, REGULATOR_MODE_IDLE}, /* 10mA - 100mA - Standby */
1083 {100000, 800000, REGULATOR_MODE_NORMAL}, /* > 100mA - Active */
1084 {-1, -1, REGULATOR_MODE_NORMAL},
1085};
1086
1087static unsigned int get_mode(int uA, const struct wm8350_dcdc_efficiency *eff)
1088{
1089 int i = 0;
1090
1091 while (eff[i].uA_load_min != -1) {
1092 if (uA >= eff[i].uA_load_min && uA <= eff[i].uA_load_max)
1093 return eff[i].mode;
1094 }
1095 return REGULATOR_MODE_NORMAL;
1096}
1097
1098/* Query the regulator for it's most efficient mode @ uV,uA
1099 * WM8350 regulator efficiency is pretty similar over
1100 * different input and output uV.
1101 */
1102static unsigned int wm8350_dcdc_get_optimum_mode(struct regulator_dev *rdev,
1103 int input_uV, int output_uV,
1104 int output_uA)
1105{
1106 int dcdc = rdev_get_id(rdev), mode;
1107
1108 switch (dcdc) {
1109 case WM8350_DCDC_1:
1110 case WM8350_DCDC_6:
1111 mode = get_mode(output_uA, dcdc1_6_efficiency);
1112 break;
1113 case WM8350_DCDC_3:
1114 case WM8350_DCDC_4:
1115 mode = get_mode(output_uA, dcdc3_4_efficiency);
1116 break;
1117 default:
1118 mode = REGULATOR_MODE_NORMAL;
1119 break;
1120 }
1121 return mode;
1122}
1123
1124static int wm8350_dcdc_is_enabled(struct regulator_dev *rdev)
1125{
1126 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
1127 int dcdc = rdev_get_id(rdev), shift;
1128
1129 if (dcdc < WM8350_DCDC_1 || dcdc > WM8350_DCDC_6)
1130 return -EINVAL;
1131
1132 shift = dcdc - WM8350_DCDC_1;
1133 return wm8350_reg_read(wm8350, WM8350_DCDC_LDO_REQUESTED)
1134 & (1 << shift);
1135}
1136
1137static int wm8350_ldo_is_enabled(struct regulator_dev *rdev)
1138{
1139 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
1140 int ldo = rdev_get_id(rdev), shift;
1141
1142 if (ldo < WM8350_LDO_1 || ldo > WM8350_LDO_4)
1143 return -EINVAL;
1144
1145 shift = (ldo - WM8350_LDO_1) + 8;
1146 return wm8350_reg_read(wm8350, WM8350_DCDC_LDO_REQUESTED)
1147 & (1 << shift);
1148}
1149
1150static struct regulator_ops wm8350_dcdc_ops = {
1151 .set_voltage = wm8350_dcdc_set_voltage,
1152 .get_voltage = wm8350_dcdc_get_voltage,
1153 .enable = wm8350_dcdc_enable,
1154 .disable = wm8350_dcdc_disable,
1155 .get_mode = wm8350_dcdc_get_mode,
1156 .set_mode = wm8350_dcdc_set_mode,
1157 .get_optimum_mode = wm8350_dcdc_get_optimum_mode,
1158 .is_enabled = wm8350_dcdc_is_enabled,
1159 .set_suspend_voltage = wm8350_dcdc_set_suspend_voltage,
1160 .set_suspend_enable = wm8350_dcdc_set_suspend_enable,
1161 .set_suspend_disable = wm8350_dcdc_set_suspend_disable,
1162 .set_suspend_mode = wm8350_dcdc_set_suspend_mode,
1163};
1164
1165static struct regulator_ops wm8350_dcdc2_5_ops = {
1166 .enable = wm8350_dcdc_enable,
1167 .disable = wm8350_dcdc_disable,
1168 .is_enabled = wm8350_dcdc_is_enabled,
1169 .set_suspend_enable = wm8350_dcdc25_set_suspend_enable,
1170 .set_suspend_disable = wm8350_dcdc25_set_suspend_disable,
1171};
1172
1173static struct regulator_ops wm8350_ldo_ops = {
1174 .set_voltage = wm8350_ldo_set_voltage,
1175 .get_voltage = wm8350_ldo_get_voltage,
1176 .enable = wm8350_ldo_enable,
1177 .disable = wm8350_ldo_disable,
1178 .is_enabled = wm8350_ldo_is_enabled,
1179 .get_mode = wm8350_ldo_get_mode,
1180 .set_suspend_voltage = wm8350_ldo_set_suspend_voltage,
1181 .set_suspend_enable = wm8350_ldo_set_suspend_enable,
1182 .set_suspend_disable = wm8350_ldo_set_suspend_disable,
1183};
1184
1185static struct regulator_ops wm8350_isink_ops = {
1186 .set_current_limit = wm8350_isink_set_current,
1187 .get_current_limit = wm8350_isink_get_current,
1188 .enable = wm8350_isink_enable,
1189 .disable = wm8350_isink_disable,
1190 .is_enabled = wm8350_isink_is_enabled,
1191};
1192
1193static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1194 {
1195 .name = "DCDC1",
1196 .id = WM8350_DCDC_1,
1197 .ops = &wm8350_dcdc_ops,
1198 .irq = WM8350_IRQ_UV_DC1,
1199 .type = REGULATOR_VOLTAGE,
1200 .owner = THIS_MODULE,
1201 },
1202 {
1203 .name = "DCDC2",
1204 .id = WM8350_DCDC_2,
1205 .ops = &wm8350_dcdc2_5_ops,
1206 .irq = WM8350_IRQ_UV_DC2,
1207 .type = REGULATOR_VOLTAGE,
1208 .owner = THIS_MODULE,
1209 },
1210 {
1211 .name = "DCDC3",
1212 .id = WM8350_DCDC_3,
1213 .ops = &wm8350_dcdc_ops,
1214 .irq = WM8350_IRQ_UV_DC3,
1215 .type = REGULATOR_VOLTAGE,
1216 .owner = THIS_MODULE,
1217 },
1218 {
1219 .name = "DCDC4",
1220 .id = WM8350_DCDC_4,
1221 .ops = &wm8350_dcdc_ops,
1222 .irq = WM8350_IRQ_UV_DC4,
1223 .type = REGULATOR_VOLTAGE,
1224 .owner = THIS_MODULE,
1225 },
1226 {
1227 .name = "DCDC5",
1228 .id = WM8350_DCDC_5,
1229 .ops = &wm8350_dcdc2_5_ops,
1230 .irq = WM8350_IRQ_UV_DC5,
1231 .type = REGULATOR_VOLTAGE,
1232 .owner = THIS_MODULE,
1233 },
1234 {
1235 .name = "DCDC6",
1236 .id = WM8350_DCDC_6,
1237 .ops = &wm8350_dcdc_ops,
1238 .irq = WM8350_IRQ_UV_DC6,
1239 .type = REGULATOR_VOLTAGE,
1240 .owner = THIS_MODULE,
1241 },
1242 {
1243 .name = "LDO1",
1244 .id = WM8350_LDO_1,
1245 .ops = &wm8350_ldo_ops,
1246 .irq = WM8350_IRQ_UV_LDO1,
1247 .type = REGULATOR_VOLTAGE,
1248 .owner = THIS_MODULE,
1249 },
1250 {
1251 .name = "LDO2",
1252 .id = WM8350_LDO_2,
1253 .ops = &wm8350_ldo_ops,
1254 .irq = WM8350_IRQ_UV_LDO2,
1255 .type = REGULATOR_VOLTAGE,
1256 .owner = THIS_MODULE,
1257 },
1258 {
1259 .name = "LDO3",
1260 .id = WM8350_LDO_3,
1261 .ops = &wm8350_ldo_ops,
1262 .irq = WM8350_IRQ_UV_LDO3,
1263 .type = REGULATOR_VOLTAGE,
1264 .owner = THIS_MODULE,
1265 },
1266 {
1267 .name = "LDO4",
1268 .id = WM8350_LDO_4,
1269 .ops = &wm8350_ldo_ops,
1270 .irq = WM8350_IRQ_UV_LDO4,
1271 .type = REGULATOR_VOLTAGE,
1272 .owner = THIS_MODULE,
1273 },
1274 {
1275 .name = "ISINKA",
1276 .id = WM8350_ISINK_A,
1277 .ops = &wm8350_isink_ops,
1278 .irq = WM8350_IRQ_CS1,
1279 .type = REGULATOR_CURRENT,
1280 .owner = THIS_MODULE,
1281 },
1282 {
1283 .name = "ISINKB",
1284 .id = WM8350_ISINK_B,
1285 .ops = &wm8350_isink_ops,
1286 .irq = WM8350_IRQ_CS2,
1287 .type = REGULATOR_CURRENT,
1288 .owner = THIS_MODULE,
1289 },
1290};
1291
1292static void pmic_uv_handler(struct wm8350 *wm8350, int irq, void *data)
1293{
1294 struct regulator_dev *rdev = (struct regulator_dev *)data;
1295
1296 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2)
1297 regulator_notifier_call_chain(rdev,
1298 REGULATOR_EVENT_REGULATION_OUT,
1299 wm8350);
1300 else
1301 regulator_notifier_call_chain(rdev,
1302 REGULATOR_EVENT_UNDER_VOLTAGE,
1303 wm8350);
1304}
1305
1306static int wm8350_regulator_probe(struct platform_device *pdev)
1307{
1308 struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev);
1309 struct regulator_dev *rdev;
1310 int ret;
1311 u16 val;
1312
1313 if (pdev->id < WM8350_DCDC_1 || pdev->id > WM8350_ISINK_B)
1314 return -ENODEV;
1315
1316 /* do any regulatior specific init */
1317 switch (pdev->id) {
1318 case WM8350_DCDC_1:
1319 val = wm8350_reg_read(wm8350, WM8350_DCDC1_LOW_POWER);
1320 wm8350->pmic.dcdc1_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
1321 break;
1322 case WM8350_DCDC_3:
1323 val = wm8350_reg_read(wm8350, WM8350_DCDC3_LOW_POWER);
1324 wm8350->pmic.dcdc3_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
1325 break;
1326 case WM8350_DCDC_4:
1327 val = wm8350_reg_read(wm8350, WM8350_DCDC4_LOW_POWER);
1328 wm8350->pmic.dcdc4_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
1329 break;
1330 case WM8350_DCDC_6:
1331 val = wm8350_reg_read(wm8350, WM8350_DCDC6_LOW_POWER);
1332 wm8350->pmic.dcdc6_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK;
1333 break;
1334 }
1335
1336
1337 /* register regulator */
1338 rdev = regulator_register(&wm8350_reg[pdev->id], &pdev->dev,
1339 dev_get_drvdata(&pdev->dev));
1340 if (IS_ERR(rdev)) {
1341 dev_err(&pdev->dev, "failed to register %s\n",
1342 wm8350_reg[pdev->id].name);
1343 return PTR_ERR(rdev);
1344 }
1345
1346 /* register regulator IRQ */
1347 ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq,
1348 pmic_uv_handler, rdev);
1349 if (ret < 0) {
1350 regulator_unregister(rdev);
1351 dev_err(&pdev->dev, "failed to register regulator %s IRQ\n",
1352 wm8350_reg[pdev->id].name);
1353 return ret;
1354 }
1355
1356 wm8350_unmask_irq(wm8350, wm8350_reg[pdev->id].irq);
1357
1358 return 0;
1359}
1360
1361static int wm8350_regulator_remove(struct platform_device *pdev)
1362{
1363 struct regulator_dev *rdev = platform_get_drvdata(pdev);
1364 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
1365
1366 wm8350_mask_irq(wm8350, wm8350_reg[pdev->id].irq);
1367 wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq);
1368
1369 regulator_unregister(rdev);
1370
1371 return 0;
1372}
1373
1374int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
1375 struct regulator_init_data *initdata)
1376{
1377 struct platform_device *pdev;
1378 int ret;
1379
1380 if (wm8350->pmic.pdev[reg])
1381 return -EBUSY;
1382
1383 pdev = platform_device_alloc("wm8350-regulator", reg);
1384 if (!pdev)
1385 return -ENOMEM;
1386
1387 wm8350->pmic.pdev[reg] = pdev;
1388
1389 initdata->driver_data = wm8350;
1390
1391 pdev->dev.platform_data = initdata;
1392 pdev->dev.parent = wm8350->dev;
1393 platform_set_drvdata(pdev, wm8350);
1394
1395 ret = platform_device_add(pdev);
1396
1397 if (ret != 0) {
1398 dev_err(wm8350->dev, "Failed to register regulator %d: %d\n",
1399 reg, ret);
1400 platform_device_del(pdev);
1401 wm8350->pmic.pdev[reg] = NULL;
1402 }
1403
1404 return ret;
1405}
1406EXPORT_SYMBOL_GPL(wm8350_register_regulator);
1407
1408static struct platform_driver wm8350_regulator_driver = {
1409 .probe = wm8350_regulator_probe,
1410 .remove = wm8350_regulator_remove,
1411 .driver = {
1412 .name = "wm8350-regulator",
1413 },
1414};
1415
1416static int __init wm8350_regulator_init(void)
1417{
1418 return platform_driver_register(&wm8350_regulator_driver);
1419}
1420subsys_initcall(wm8350_regulator_init);
1421
1422static void __exit wm8350_regulator_exit(void)
1423{
1424 platform_driver_unregister(&wm8350_regulator_driver);
1425}
1426module_exit(wm8350_regulator_exit);
1427
1428/* Module information */
1429MODULE_AUTHOR("Liam Girdwood");
1430MODULE_DESCRIPTION("WM8350 voltage and current regulator driver");
1431MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
new file mode 100644
index 000000000000..48b372e038a8
--- /dev/null
+++ b/drivers/regulator/wm8400-regulator.c
@@ -0,0 +1,368 @@
1/*
2 * Regulator support for WM8400
3 *
4 * Copyright 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 */
14
15#include <linux/bug.h>
16#include <linux/err.h>
17#include <linux/kernel.h>
18#include <linux/regulator/driver.h>
19#include <linux/mfd/wm8400-private.h>
20
21static int wm8400_ldo_is_enabled(struct regulator_dev *dev)
22{
23 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
24 u16 val;
25
26 val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev));
27 return (val & WM8400_LDO1_ENA) != 0;
28}
29
30static int wm8400_ldo_enable(struct regulator_dev *dev)
31{
32 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
33
34 return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev),
35 WM8400_LDO1_ENA, WM8400_LDO1_ENA);
36}
37
38static int wm8400_ldo_disable(struct regulator_dev *dev)
39{
40 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
41
42 return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev),
43 WM8400_LDO1_ENA, 0);
44}
45
46static int wm8400_ldo_get_voltage(struct regulator_dev *dev)
47{
48 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
49 u16 val;
50
51 val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev));
52 val &= WM8400_LDO1_VSEL_MASK;
53
54 if (val < 15)
55 return 900000 + (val * 50000);
56 else
57 return 1600000 + ((val - 14) * 100000);
58}
59
60static int wm8400_ldo_set_voltage(struct regulator_dev *dev,
61 int min_uV, int max_uV)
62{
63 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
64 u16 val;
65
66 if (min_uV < 900000 || min_uV > 3300000)
67 return -EINVAL;
68
69 if (min_uV < 1700000) {
70 /* Steps of 50mV from 900mV; */
71 val = (min_uV - 850001) / 50000;
72
73 if ((val * 50000) + 900000 > max_uV)
74 return -EINVAL;
75 BUG_ON((val * 50000) + 900000 < min_uV);
76 } else {
77 /* Steps of 100mV from 1700mV */
78 val = ((min_uV - 1600001) / 100000);
79
80 if ((val * 100000) + 1700000 > max_uV)
81 return -EINVAL;
82 BUG_ON((val * 100000) + 1700000 < min_uV);
83
84 val += 0xf;
85 }
86
87 return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev),
88 WM8400_LDO1_VSEL_MASK, val);
89}
90
91static struct regulator_ops wm8400_ldo_ops = {
92 .is_enabled = wm8400_ldo_is_enabled,
93 .enable = wm8400_ldo_enable,
94 .disable = wm8400_ldo_disable,
95 .get_voltage = wm8400_ldo_get_voltage,
96 .set_voltage = wm8400_ldo_set_voltage,
97};
98
99static int wm8400_dcdc_is_enabled(struct regulator_dev *dev)
100{
101 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
102 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
103 u16 val;
104
105 val = wm8400_reg_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset);
106 return (val & WM8400_DC1_ENA) != 0;
107}
108
109static int wm8400_dcdc_enable(struct regulator_dev *dev)
110{
111 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
112 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
113
114 return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
115 WM8400_DC1_ENA, WM8400_DC1_ENA);
116}
117
118static int wm8400_dcdc_disable(struct regulator_dev *dev)
119{
120 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
121 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
122
123 return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
124 WM8400_DC1_ENA, 0);
125}
126
127static int wm8400_dcdc_get_voltage(struct regulator_dev *dev)
128{
129 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
130 u16 val;
131 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
132
133 val = wm8400_reg_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset);
134 val &= WM8400_DC1_VSEL_MASK;
135
136 return 850000 + (25000 * val);
137}
138
139static int wm8400_dcdc_set_voltage(struct regulator_dev *dev,
140 int min_uV, int max_uV)
141{
142 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
143 u16 val;
144 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
145
146 if (min_uV < 850000)
147 return -EINVAL;
148
149 val = (min_uV - 825001) / 25000;
150
151 if (850000 + (25000 * val) > max_uV)
152 return -EINVAL;
153 BUG_ON(850000 + (25000 * val) < min_uV);
154
155 return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
156 WM8400_DC1_VSEL_MASK, val);
157}
158
159static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev)
160{
161 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
162 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
163 u16 data[2];
164 int ret;
165
166 ret = wm8400_block_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset, 2,
167 data);
168 if (ret != 0)
169 return 0;
170
171 /* Datasheet: hibernate */
172 if (data[0] & WM8400_DC1_SLEEP)
173 return REGULATOR_MODE_STANDBY;
174
175 /* Datasheet: standby */
176 if (!(data[0] & WM8400_DC1_ACTIVE))
177 return REGULATOR_MODE_IDLE;
178
179 /* Datasheet: active with or without force PWM */
180 if (data[1] & WM8400_DC1_FRC_PWM)
181 return REGULATOR_MODE_FAST;
182 else
183 return REGULATOR_MODE_NORMAL;
184}
185
186static int wm8400_dcdc_set_mode(struct regulator_dev *dev, unsigned int mode)
187{
188 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
189 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
190 int ret;
191
192 switch (mode) {
193 case REGULATOR_MODE_FAST:
194 /* Datasheet: active with force PWM */
195 ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
196 WM8400_DC1_FRC_PWM, WM8400_DC1_FRC_PWM);
197 if (ret != 0)
198 return ret;
199
200 return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
201 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
202 WM8400_DC1_ACTIVE);
203
204 case REGULATOR_MODE_NORMAL:
205 /* Datasheet: active */
206 ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
207 WM8400_DC1_FRC_PWM, 0);
208 if (ret != 0)
209 return ret;
210
211 return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
212 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
213 WM8400_DC1_ACTIVE);
214
215 case REGULATOR_MODE_IDLE:
216 /* Datasheet: standby */
217 ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
218 WM8400_DC1_ACTIVE, 0);
219 if (ret != 0)
220 return ret;
221 return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
222 WM8400_DC1_SLEEP, 0);
223
224 default:
225 return -EINVAL;
226 }
227}
228
229static unsigned int wm8400_dcdc_get_optimum_mode(struct regulator_dev *dev,
230 int input_uV, int output_uV,
231 int load_uA)
232{
233 return REGULATOR_MODE_NORMAL;
234}
235
236static struct regulator_ops wm8400_dcdc_ops = {
237 .is_enabled = wm8400_dcdc_is_enabled,
238 .enable = wm8400_dcdc_enable,
239 .disable = wm8400_dcdc_disable,
240 .get_voltage = wm8400_dcdc_get_voltage,
241 .set_voltage = wm8400_dcdc_set_voltage,
242 .get_mode = wm8400_dcdc_get_mode,
243 .set_mode = wm8400_dcdc_set_mode,
244 .get_optimum_mode = wm8400_dcdc_get_optimum_mode,
245};
246
247static struct regulator_desc regulators[] = {
248 {
249 .name = "LDO1",
250 .id = WM8400_LDO1,
251 .ops = &wm8400_ldo_ops,
252 .type = REGULATOR_VOLTAGE,
253 .owner = THIS_MODULE,
254 },
255 {
256 .name = "LDO2",
257 .id = WM8400_LDO2,
258 .ops = &wm8400_ldo_ops,
259 .type = REGULATOR_VOLTAGE,
260 .owner = THIS_MODULE,
261 },
262 {
263 .name = "LDO3",
264 .id = WM8400_LDO3,
265 .ops = &wm8400_ldo_ops,
266 .type = REGULATOR_VOLTAGE,
267 .owner = THIS_MODULE,
268 },
269 {
270 .name = "LDO4",
271 .id = WM8400_LDO4,
272 .ops = &wm8400_ldo_ops,
273 .type = REGULATOR_VOLTAGE,
274 .owner = THIS_MODULE,
275 },
276 {
277 .name = "DCDC1",
278 .id = WM8400_DCDC1,
279 .ops = &wm8400_dcdc_ops,
280 .type = REGULATOR_VOLTAGE,
281 .owner = THIS_MODULE,
282 },
283 {
284 .name = "DCDC2",
285 .id = WM8400_DCDC2,
286 .ops = &wm8400_dcdc_ops,
287 .type = REGULATOR_VOLTAGE,
288 .owner = THIS_MODULE,
289 },
290};
291
292static int __init wm8400_regulator_probe(struct platform_device *pdev)
293{
294 struct regulator_dev *rdev;
295
296 rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
297 pdev->dev.driver_data);
298
299 if (IS_ERR(rdev))
300 return PTR_ERR(rdev);
301
302 return 0;
303}
304
305static int __devexit wm8400_regulator_remove(struct platform_device *pdev)
306{
307 struct regulator_dev *rdev = platform_get_drvdata(pdev);
308
309 regulator_unregister(rdev);
310
311 return 0;
312}
313
314static struct platform_driver wm8400_regulator_driver = {
315 .driver = {
316 .name = "wm8400-regulator",
317 },
318 .probe = wm8400_regulator_probe,
319 .remove = __devexit_p(wm8400_regulator_remove),
320};
321
322/**
323 * wm8400_register_regulator - enable software control of a WM8400 regulator
324 *
325 * This function enables software control of a WM8400 regulator via
326 * the regulator API. It is intended to be called from the
327 * platform_init() callback of the WM8400 MFD driver.
328 *
329 * @param dev The WM8400 device to operate on.
330 * @param reg The regulator to control.
331 * @param initdata Regulator initdata for the regulator.
332 */
333int wm8400_register_regulator(struct device *dev, int reg,
334 struct regulator_init_data *initdata)
335{
336 struct wm8400 *wm8400 = dev->driver_data;
337
338 if (wm8400->regulators[reg].name)
339 return -EBUSY;
340
341 initdata->driver_data = wm8400;
342
343 wm8400->regulators[reg].name = "wm8400-regulator";
344 wm8400->regulators[reg].id = reg;
345 wm8400->regulators[reg].dev.parent = dev;
346 wm8400->regulators[reg].dev.driver_data = wm8400;
347 wm8400->regulators[reg].dev.platform_data = initdata;
348
349 return platform_device_register(&wm8400->regulators[reg]);
350}
351EXPORT_SYMBOL_GPL(wm8400_register_regulator);
352
353static int __init wm8400_regulator_init(void)
354{
355 return platform_driver_register(&wm8400_regulator_driver);
356}
357module_init(wm8400_regulator_init);
358
359static void __exit wm8400_regulator_exit(void)
360{
361 platform_driver_unregister(&wm8400_regulator_driver);
362}
363module_exit(wm8400_regulator_exit);
364
365MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
366MODULE_DESCRIPTION("WM8400 regulator driver");
367MODULE_LICENSE("GPL");
368MODULE_ALIAS("platform:wm8400-regulator");
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index b23af0c2a869..963ad0b6a4e9 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -913,6 +913,92 @@ static inline int cmos_poweroff(struct device *dev)
913 * predate even PNPBIOS should set up platform_bus devices. 913 * predate even PNPBIOS should set up platform_bus devices.
914 */ 914 */
915 915
916#ifdef CONFIG_ACPI
917
918#include <linux/acpi.h>
919
920#ifdef CONFIG_PM
921static u32 rtc_handler(void *context)
922{
923 acpi_clear_event(ACPI_EVENT_RTC);
924 acpi_disable_event(ACPI_EVENT_RTC, 0);
925 return ACPI_INTERRUPT_HANDLED;
926}
927
928static inline void rtc_wake_setup(void)
929{
930 acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
931 /*
932 * After the RTC handler is installed, the Fixed_RTC event should
933 * be disabled. Only when the RTC alarm is set will it be enabled.
934 */
935 acpi_clear_event(ACPI_EVENT_RTC);
936 acpi_disable_event(ACPI_EVENT_RTC, 0);
937}
938
939static void rtc_wake_on(struct device *dev)
940{
941 acpi_clear_event(ACPI_EVENT_RTC);
942 acpi_enable_event(ACPI_EVENT_RTC, 0);
943}
944
945static void rtc_wake_off(struct device *dev)
946{
947 acpi_disable_event(ACPI_EVENT_RTC, 0);
948}
949#else
950#define rtc_wake_setup() do{}while(0)
951#define rtc_wake_on NULL
952#define rtc_wake_off NULL
953#endif
954
955/* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find
956 * its device node and pass extra config data. This helps its driver use
957 * capabilities that the now-obsolete mc146818 didn't have, and informs it
958 * that this board's RTC is wakeup-capable (per ACPI spec).
959 */
960static struct cmos_rtc_board_info acpi_rtc_info;
961
962static void __devinit
963cmos_wake_setup(struct device *dev)
964{
965 if (acpi_disabled)
966 return;
967
968 rtc_wake_setup();
969 acpi_rtc_info.wake_on = rtc_wake_on;
970 acpi_rtc_info.wake_off = rtc_wake_off;
971
972 /* workaround bug in some ACPI tables */
973 if (acpi_gbl_FADT.month_alarm && !acpi_gbl_FADT.day_alarm) {
974 dev_dbg(dev, "bogus FADT month_alarm (%d)\n",
975 acpi_gbl_FADT.month_alarm);
976 acpi_gbl_FADT.month_alarm = 0;
977 }
978
979 acpi_rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm;
980 acpi_rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm;
981 acpi_rtc_info.rtc_century = acpi_gbl_FADT.century;
982
983 /* NOTE: S4_RTC_WAKE is NOT currently useful to Linux */
984 if (acpi_gbl_FADT.flags & ACPI_FADT_S4_RTC_WAKE)
985 dev_info(dev, "RTC can wake from S4\n");
986
987 dev->platform_data = &acpi_rtc_info;
988
989 /* RTC always wakes from S1/S2/S3, and often S4/STD */
990 device_init_wakeup(dev, 1);
991}
992
993#else
994
995static void __devinit
996cmos_wake_setup(struct device *dev)
997{
998}
999
1000#endif
1001
916#ifdef CONFIG_PNP 1002#ifdef CONFIG_PNP
917 1003
918#include <linux/pnp.h> 1004#include <linux/pnp.h>
@@ -920,6 +1006,8 @@ static inline int cmos_poweroff(struct device *dev)
920static int __devinit 1006static int __devinit
921cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) 1007cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
922{ 1008{
1009 cmos_wake_setup(&pnp->dev);
1010
923 if (pnp_port_start(pnp,0) == 0x70 && !pnp_irq_valid(pnp,0)) 1011 if (pnp_port_start(pnp,0) == 0x70 && !pnp_irq_valid(pnp,0))
924 /* Some machines contain a PNP entry for the RTC, but 1012 /* Some machines contain a PNP entry for the RTC, but
925 * don't define the IRQ. It should always be safe to 1013 * don't define the IRQ. It should always be safe to
@@ -997,6 +1085,7 @@ static struct pnp_driver cmos_pnp_driver = {
997 1085
998static int __init cmos_platform_probe(struct platform_device *pdev) 1086static int __init cmos_platform_probe(struct platform_device *pdev)
999{ 1087{
1088 cmos_wake_setup(&pdev->dev);
1000 return cmos_do_probe(&pdev->dev, 1089 return cmos_do_probe(&pdev->dev,
1001 platform_get_resource(pdev, IORESOURCE_IO, 0), 1090 platform_get_resource(pdev, IORESOURCE_IO, 0),
1002 platform_get_irq(pdev, 0)); 1091 platform_get_irq(pdev, 0));
@@ -1031,29 +1120,32 @@ static struct platform_driver cmos_platform_driver = {
1031 1120
1032static int __init cmos_init(void) 1121static int __init cmos_init(void)
1033{ 1122{
1123 int retval = 0;
1124
1034#ifdef CONFIG_PNP 1125#ifdef CONFIG_PNP
1035 if (pnp_platform_devices) 1126 pnp_register_driver(&cmos_pnp_driver);
1036 return pnp_register_driver(&cmos_pnp_driver); 1127#endif
1037 else 1128
1038 return platform_driver_probe(&cmos_platform_driver, 1129 if (!cmos_rtc.dev)
1039 cmos_platform_probe); 1130 retval = platform_driver_probe(&cmos_platform_driver,
1040#else 1131 cmos_platform_probe);
1041 return platform_driver_probe(&cmos_platform_driver, 1132
1042 cmos_platform_probe); 1133 if (retval == 0)
1043#endif /* CONFIG_PNP */ 1134 return 0;
1135
1136#ifdef CONFIG_PNP
1137 pnp_unregister_driver(&cmos_pnp_driver);
1138#endif
1139 return retval;
1044} 1140}
1045module_init(cmos_init); 1141module_init(cmos_init);
1046 1142
1047static void __exit cmos_exit(void) 1143static void __exit cmos_exit(void)
1048{ 1144{
1049#ifdef CONFIG_PNP 1145#ifdef CONFIG_PNP
1050 if (pnp_platform_devices) 1146 pnp_unregister_driver(&cmos_pnp_driver);
1051 pnp_unregister_driver(&cmos_pnp_driver); 1147#endif
1052 else
1053 platform_driver_unregister(&cmos_platform_driver);
1054#else
1055 platform_driver_unregister(&cmos_platform_driver); 1148 platform_driver_unregister(&cmos_platform_driver);
1056#endif /* CONFIG_PNP */
1057} 1149}
1058module_exit(cmos_exit); 1150module_exit(cmos_exit);
1059 1151
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 8f83fc994f50..f5e618562c5f 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -2913,7 +2913,7 @@ claw_new_device(struct ccwgroup_device *cgdev)
2913 if (ret != 0) { 2913 if (ret != 0) {
2914 printk(KERN_WARNING 2914 printk(KERN_WARNING
2915 "claw: ccw_device_set_online %s WRITE failed " 2915 "claw: ccw_device_set_online %s WRITE failed "
2916 "with ret = %d\n", dev_name(&cgdev->cdev[WRITE]->dev) 2916 "with ret = %d\n", dev_name(&cgdev->cdev[WRITE]->dev),
2917 ret); 2917 ret);
2918 goto out; 2918 goto out;
2919 } 2919 }
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index d3b211af4e1c..403ecad48d4b 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1640,6 +1640,7 @@ config ATARI_SCSI
1640 tristate "Atari native SCSI support" 1640 tristate "Atari native SCSI support"
1641 depends on ATARI && SCSI 1641 depends on ATARI && SCSI
1642 select SCSI_SPI_ATTRS 1642 select SCSI_SPI_ATTRS
1643 select NVRAM
1643 ---help--- 1644 ---help---
1644 If you have an Atari with built-in NCR5380 SCSI controller (TT, 1645 If you have an Atari with built-in NCR5380 SCSI controller (TT,
1645 Falcon, ...) say Y to get it supported. Of course also, if you have 1646 Falcon, ...) say Y to get it supported. Of course also, if you have
@@ -1670,14 +1671,6 @@ config ATARI_SCSI_RESET_BOOT
1670 boot process fractionally longer but may assist recovery from errors 1671 boot process fractionally longer but may assist recovery from errors
1671 that leave the devices with SCSI operations partway completed. 1672 that leave the devices with SCSI operations partway completed.
1672 1673
1673config TT_DMA_EMUL
1674 bool "Hades SCSI DMA emulator"
1675 depends on ATARI_SCSI && HADES
1676 help
1677 This option enables code which emulates the TT SCSI DMA chip on the
1678 Hades. This increases the SCSI transfer rates at least ten times
1679 compared to PIO transfers.
1680
1681config MAC_SCSI 1674config MAC_SCSI
1682 bool "Macintosh NCR5380 SCSI" 1675 bool "Macintosh NCR5380 SCSI"
1683 depends on MAC && SCSI=y 1676 depends on MAC && SCSI=y
diff --git a/drivers/scsi/atari_dma_emul.c b/drivers/scsi/atari_dma_emul.c
deleted file mode 100644
index cdc710ea00fa..000000000000
--- a/drivers/scsi/atari_dma_emul.c
+++ /dev/null
@@ -1,468 +0,0 @@
1/*
2 * atari_dma_emul.c -- TT SCSI DMA emulator for the Hades.
3 *
4 * Copyright 1997 Wout Klaren <W.Klaren@inter.nl.net>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 *
10 * This code was written using the Hades TOS source code as a
11 * reference. This source code can be found on the home page
12 * of Medusa Computer Systems.
13 *
14 * Version 0.1, 1997-09-24.
15 *
16 * This code should be considered experimental. It has only been
17 * tested on a Hades with a 68060. It might not work on a Hades
18 * with a 68040. Make backups of your hard drives before using
19 * this code.
20 */
21
22#include <linux/compiler.h>
23#include <asm/thread_info.h>
24#include <asm/uaccess.h>
25
26#define hades_dma_ctrl (*(unsigned char *) 0xffff8717)
27#define hades_psdm_reg (*(unsigned char *) 0xffff8741)
28
29#define TRANSFER_SIZE 16
30
31struct m68040_frame {
32 unsigned long effaddr; /* effective address */
33 unsigned short ssw; /* special status word */
34 unsigned short wb3s; /* write back 3 status */
35 unsigned short wb2s; /* write back 2 status */
36 unsigned short wb1s; /* write back 1 status */
37 unsigned long faddr; /* fault address */
38 unsigned long wb3a; /* write back 3 address */
39 unsigned long wb3d; /* write back 3 data */
40 unsigned long wb2a; /* write back 2 address */
41 unsigned long wb2d; /* write back 2 data */
42 unsigned long wb1a; /* write back 1 address */
43 unsigned long wb1dpd0; /* write back 1 data/push data 0*/
44 unsigned long pd1; /* push data 1*/
45 unsigned long pd2; /* push data 2*/
46 unsigned long pd3; /* push data 3*/
47};
48
49static void writeback (unsigned short wbs, unsigned long wba,
50 unsigned long wbd, void *old_buserr)
51{
52 mm_segment_t fs = get_fs();
53 static void *save_buserr;
54
55 __asm__ __volatile__ ("movec.l %%vbr,%%a0\n\t"
56 "move.l %0,8(%%a0)\n\t"
57 :
58 : "r" (&&bus_error)
59 : "a0" );
60
61 save_buserr = old_buserr;
62
63 set_fs (MAKE_MM_SEG(wbs & WBTM_040));
64
65 switch (wbs & WBSIZ_040) {
66 case BA_SIZE_BYTE:
67 put_user (wbd & 0xff, (char *)wba);
68 break;
69 case BA_SIZE_WORD:
70 put_user (wbd & 0xffff, (short *)wba);
71 break;
72 case BA_SIZE_LONG:
73 put_user (wbd, (int *)wba);
74 break;
75 }
76
77 set_fs (fs);
78 return;
79
80bus_error:
81 __asm__ __volatile__ ("cmp.l %0,2(%%sp)\n\t"
82 "bcs.s .jump_old\n\t"
83 "cmp.l %1,2(%%sp)\n\t"
84 "bls.s .restore_old\n"
85 ".jump_old:\n\t"
86 "move.l %2,-(%%sp)\n\t"
87 "rts\n"
88 ".restore_old:\n\t"
89 "move.l %%a0,-(%%sp)\n\t"
90 "movec.l %%vbr,%%a0\n\t"
91 "move.l %2,8(%%a0)\n\t"
92 "move.l (%%sp)+,%%a0\n\t"
93 "rte\n\t"
94 :
95 : "i" (writeback), "i" (&&bus_error),
96 "m" (save_buserr) );
97}
98
99/*
100 * static inline void set_restdata_reg(unsigned char *cur_addr)
101 *
102 * Set the rest data register if necessary.
103 */
104
105static inline void set_restdata_reg(unsigned char *cur_addr)
106{
107 if (((long) cur_addr & ~3) != 0)
108 tt_scsi_dma.dma_restdata =
109 *((unsigned long *) ((long) cur_addr & ~3));
110}
111
112/*
113 * void hades_dma_emulator(int irq, void *dummy)
114 *
115 * This code emulates TT SCSI DMA on the Hades.
116 *
117 * Note the following:
118 *
119 * 1. When there is no byte available to read from the SCSI bus, or
120 * when a byte cannot yet bet written to the SCSI bus, a bus
121 * error occurs when reading or writing the pseudo DMA data
122 * register (hades_psdm_reg). We have to catch this bus error
123 * and try again to read or write the byte. If after several tries
124 * we still get a bus error, the interrupt handler is left. When
125 * the byte can be read or written, the interrupt handler is
126 * called again.
127 *
128 * 2. The SCSI interrupt must be disabled in this interrupt handler.
129 *
130 * 3. If we set the EOP signal, the SCSI controller still expects one
131 * byte to be read or written. Therefore the last byte is transferred
132 * separately, after setting the EOP signal.
133 *
134 * 4. When this function is left, the address pointer (start_addr) is
135 * converted to a physical address. Because it points one byte
136 * further than the last transferred byte, it can point outside the
137 * current page. If virt_to_phys() is called with this address we
138 * might get an access error. Therefore virt_to_phys() is called with
139 * start_addr - 1 if the count has reached zero. The result is
140 * increased with one.
141 */
142
143static irqreturn_t hades_dma_emulator(int irq, void *dummy)
144{
145 unsigned long dma_base;
146 register unsigned long dma_cnt asm ("d3");
147 static long save_buserr;
148 register unsigned long save_sp asm ("d4");
149 register int tries asm ("d5");
150 register unsigned char *start_addr asm ("a3"), *end_addr asm ("a4");
151 register unsigned char *eff_addr;
152 register unsigned char *psdm_reg;
153 unsigned long rem;
154
155 atari_disable_irq(IRQ_TT_MFP_SCSI);
156
157 /*
158 * Read the dma address and count registers.
159 */
160
161 dma_base = SCSI_DMA_READ_P(dma_addr);
162 dma_cnt = SCSI_DMA_READ_P(dma_cnt);
163
164 /*
165 * Check if DMA is still enabled.
166 */
167
168 if ((tt_scsi_dma.dma_ctrl & 2) == 0)
169 {
170 atari_enable_irq(IRQ_TT_MFP_SCSI);
171 return IRQ_HANDLED;
172 }
173
174 if (dma_cnt == 0)
175 {
176 printk(KERN_NOTICE "DMA emulation: count is zero.\n");
177 tt_scsi_dma.dma_ctrl &= 0xfd; /* DMA ready. */
178 atari_enable_irq(IRQ_TT_MFP_SCSI);
179 return IRQ_HANDLED;
180 }
181
182 /*
183 * Install new bus error routine.
184 */
185
186 __asm__ __volatile__ ("movec.l %%vbr,%%a0\n\t"
187 "move.l 8(%%a0),%0\n\t"
188 "move.l %1,8(%%a0)\n\t"
189 : "=&r" (save_buserr)
190 : "r" (&&scsi_bus_error)
191 : "a0" );
192
193 hades_dma_ctrl &= 0xfc; /* Bus error and EOP off. */
194
195 /*
196 * Save the stack pointer.
197 */
198
199 __asm__ __volatile__ ("move.l %%sp,%0\n\t"
200 : "=&r" (save_sp) );
201
202 tries = 100; /* Maximum number of bus errors. */
203 start_addr = phys_to_virt(dma_base);
204 end_addr = start_addr + dma_cnt;
205
206scsi_loop:
207 dma_cnt--;
208 rem = dma_cnt & (TRANSFER_SIZE - 1);
209 dma_cnt &= ~(TRANSFER_SIZE - 1);
210 psdm_reg = &hades_psdm_reg;
211
212 if (tt_scsi_dma.dma_ctrl & 1) /* Read or write? */
213 {
214 /*
215 * SCSI write. Abort when count is zero.
216 */
217
218 switch (rem)
219 {
220 case 0:
221 while (dma_cnt > 0)
222 {
223 dma_cnt -= TRANSFER_SIZE;
224
225 *psdm_reg = *start_addr++;
226 case 15:
227 *psdm_reg = *start_addr++;
228 case 14:
229 *psdm_reg = *start_addr++;
230 case 13:
231 *psdm_reg = *start_addr++;
232 case 12:
233 *psdm_reg = *start_addr++;
234 case 11:
235 *psdm_reg = *start_addr++;
236 case 10:
237 *psdm_reg = *start_addr++;
238 case 9:
239 *psdm_reg = *start_addr++;
240 case 8:
241 *psdm_reg = *start_addr++;
242 case 7:
243 *psdm_reg = *start_addr++;
244 case 6:
245 *psdm_reg = *start_addr++;
246 case 5:
247 *psdm_reg = *start_addr++;
248 case 4:
249 *psdm_reg = *start_addr++;
250 case 3:
251 *psdm_reg = *start_addr++;
252 case 2:
253 *psdm_reg = *start_addr++;
254 case 1:
255 *psdm_reg = *start_addr++;
256 }
257 }
258
259 hades_dma_ctrl |= 1; /* Set EOP. */
260 udelay(10);
261 *psdm_reg = *start_addr++; /* Dummy byte. */
262 tt_scsi_dma.dma_ctrl &= 0xfd; /* DMA ready. */
263 }
264 else
265 {
266 /*
267 * SCSI read. Abort when count is zero.
268 */
269
270 switch (rem)
271 {
272 case 0:
273 while (dma_cnt > 0)
274 {
275 dma_cnt -= TRANSFER_SIZE;
276
277 *start_addr++ = *psdm_reg;
278 case 15:
279 *start_addr++ = *psdm_reg;
280 case 14:
281 *start_addr++ = *psdm_reg;
282 case 13:
283 *start_addr++ = *psdm_reg;
284 case 12:
285 *start_addr++ = *psdm_reg;
286 case 11:
287 *start_addr++ = *psdm_reg;
288 case 10:
289 *start_addr++ = *psdm_reg;
290 case 9:
291 *start_addr++ = *psdm_reg;
292 case 8:
293 *start_addr++ = *psdm_reg;
294 case 7:
295 *start_addr++ = *psdm_reg;
296 case 6:
297 *start_addr++ = *psdm_reg;
298 case 5:
299 *start_addr++ = *psdm_reg;
300 case 4:
301 *start_addr++ = *psdm_reg;
302 case 3:
303 *start_addr++ = *psdm_reg;
304 case 2:
305 *start_addr++ = *psdm_reg;
306 case 1:
307 *start_addr++ = *psdm_reg;
308 }
309 }
310
311 hades_dma_ctrl |= 1; /* Set EOP. */
312 udelay(10);
313 *start_addr++ = *psdm_reg;
314 tt_scsi_dma.dma_ctrl &= 0xfd; /* DMA ready. */
315
316 set_restdata_reg(start_addr);
317 }
318
319 if (start_addr != end_addr)
320 printk(KERN_CRIT "DMA emulation: FATAL: Count is not zero at end of transfer.\n");
321
322 dma_cnt = end_addr - start_addr;
323
324scsi_end:
325 dma_base = (dma_cnt == 0) ? virt_to_phys(start_addr - 1) + 1 :
326 virt_to_phys(start_addr);
327
328 SCSI_DMA_WRITE_P(dma_addr, dma_base);
329 SCSI_DMA_WRITE_P(dma_cnt, dma_cnt);
330
331 /*
332 * Restore old bus error routine.
333 */
334
335 __asm__ __volatile__ ("movec.l %%vbr,%%a0\n\t"
336 "move.l %0,8(%%a0)\n\t"
337 :
338 : "r" (save_buserr)
339 : "a0" );
340
341 atari_enable_irq(IRQ_TT_MFP_SCSI);
342
343 return IRQ_HANDLED;
344
345scsi_bus_error:
346 /*
347 * First check if the bus error is caused by our code.
348 * If not, call the original handler.
349 */
350
351 __asm__ __volatile__ ("cmp.l %0,2(%%sp)\n\t"
352 "bcs.s .old_vector\n\t"
353 "cmp.l %1,2(%%sp)\n\t"
354 "bls.s .scsi_buserr\n"
355 ".old_vector:\n\t"
356 "move.l %2,-(%%sp)\n\t"
357 "rts\n"
358 ".scsi_buserr:\n\t"
359 :
360 : "i" (&&scsi_loop), "i" (&&scsi_end),
361 "m" (save_buserr) );
362
363 if (CPU_IS_060)
364 {
365 /*
366 * Get effective address and restore the stack.
367 */
368
369 __asm__ __volatile__ ("move.l 8(%%sp),%0\n\t"
370 "move.l %1,%%sp\n\t"
371 : "=a&" (eff_addr)
372 : "r" (save_sp) );
373 }
374 else
375 {
376 register struct m68040_frame *frame;
377
378 __asm__ __volatile__ ("lea 8(%%sp),%0\n\t"
379 : "=a&" (frame) );
380
381 if (tt_scsi_dma.dma_ctrl & 1)
382 {
383 /*
384 * Bus error while writing.
385 */
386
387 if (frame->wb3s & WBV_040)
388 {
389 if (frame->wb3a == (long) &hades_psdm_reg)
390 start_addr--;
391 else
392 writeback(frame->wb3s, frame->wb3a,
393 frame->wb3d, &&scsi_bus_error);
394 }
395
396 if (frame->wb2s & WBV_040)
397 {
398 if (frame->wb2a == (long) &hades_psdm_reg)
399 start_addr--;
400 else
401 writeback(frame->wb2s, frame->wb2a,
402 frame->wb2d, &&scsi_bus_error);
403 }
404
405 if (frame->wb1s & WBV_040)
406 {
407 if (frame->wb1a == (long) &hades_psdm_reg)
408 start_addr--;
409 }
410 }
411 else
412 {
413 /*
414 * Bus error while reading.
415 */
416
417 if (frame->wb3s & WBV_040)
418 writeback(frame->wb3s, frame->wb3a,
419 frame->wb3d, &&scsi_bus_error);
420 }
421
422 eff_addr = (unsigned char *) frame->faddr;
423
424 __asm__ __volatile__ ("move.l %0,%%sp\n\t"
425 :
426 : "r" (save_sp) );
427 }
428
429 dma_cnt = end_addr - start_addr;
430
431 if (eff_addr == &hades_psdm_reg)
432 {
433 /*
434 * Bus error occurred while reading the pseudo
435 * DMA register. Time out.
436 */
437
438 tries--;
439
440 if (tries <= 0)
441 {
442 if ((tt_scsi_dma.dma_ctrl & 1) == 0) /* Read or write? */
443 set_restdata_reg(start_addr);
444
445 if (dma_cnt <= 1)
446 printk(KERN_CRIT "DMA emulation: Fatal "
447 "error while %s the last byte.\n",
448 (tt_scsi_dma.dma_ctrl & 1)
449 ? "writing" : "reading");
450
451 goto scsi_end;
452 }
453 else
454 goto scsi_loop;
455 }
456 else
457 {
458 /*
459 * Bus error during pseudo DMA transfer.
460 * Terminate the DMA transfer.
461 */
462
463 hades_dma_ctrl |= 3; /* Set EOP and bus error. */
464 if ((tt_scsi_dma.dma_ctrl & 1) == 0) /* Read or write? */
465 set_restdata_reg(start_addr);
466 goto scsi_end;
467 }
468}
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index f5732d8f67fe..21fe07f9df87 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -249,10 +249,6 @@ static int setup_hostid = -1;
249module_param(setup_hostid, int, 0); 249module_param(setup_hostid, int, 0);
250 250
251 251
252#if defined(CONFIG_TT_DMA_EMUL)
253#include "atari_dma_emul.c"
254#endif
255
256#if defined(REAL_DMA) 252#if defined(REAL_DMA)
257 253
258static int scsi_dma_is_ignored_buserr(unsigned char dma_stat) 254static int scsi_dma_is_ignored_buserr(unsigned char dma_stat)
@@ -695,21 +691,8 @@ int atari_scsi_detect(struct scsi_host_template *host)
695#ifdef REAL_DMA 691#ifdef REAL_DMA
696 tt_scsi_dma.dma_ctrl = 0; 692 tt_scsi_dma.dma_ctrl = 0;
697 atari_dma_residual = 0; 693 atari_dma_residual = 0;
698#ifdef CONFIG_TT_DMA_EMUL 694
699 if (MACH_IS_HADES) { 695 if (MACH_IS_MEDUSA) {
700 if (request_irq(IRQ_AUTO_2, hades_dma_emulator,
701 IRQ_TYPE_PRIO, "Hades DMA emulator",
702 hades_dma_emulator)) {
703 printk(KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting (MACH_IS_HADES)",IRQ_AUTO_2);
704 free_irq(IRQ_TT_MFP_SCSI, instance);
705 scsi_unregister(atari_scsi_host);
706 atari_stram_free(atari_dma_buffer);
707 atari_dma_buffer = 0;
708 return 0;
709 }
710 }
711#endif
712 if (MACH_IS_MEDUSA || MACH_IS_HADES) {
713 /* While the read overruns (described by Drew Eckhardt in 696 /* While the read overruns (described by Drew Eckhardt in
714 * NCR5380.c) never happened on TTs, they do in fact on the Medusa 697 * NCR5380.c) never happened on TTs, they do in fact on the Medusa
715 * (This was the cause why SCSI didn't work right for so long 698 * (This was the cause why SCSI didn't work right for so long
@@ -1007,11 +990,7 @@ static unsigned long atari_dma_xfer_len(unsigned long wanted_len,
1007 Scsi_Cmnd *cmd, int write_flag) 990 Scsi_Cmnd *cmd, int write_flag)
1008{ 991{
1009 unsigned long possible_len, limit; 992 unsigned long possible_len, limit;
1010#ifndef CONFIG_TT_DMA_EMUL 993
1011 if (MACH_IS_HADES)
1012 /* Hades has no SCSI DMA at all :-( Always force use of PIO */
1013 return 0;
1014#endif
1015 if (IS_A_TT()) 994 if (IS_A_TT())
1016 /* TT SCSI DMA can transfer arbitrary #bytes */ 995 /* TT SCSI DMA can transfer arbitrary #bytes */
1017 return wanted_len; 996 return wanted_len;
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index d4104a3bbe87..d3ca7d32abe0 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2969,6 +2969,9 @@ static int __init serial8250_init(void)
2969 "%d ports, IRQ sharing %sabled\n", nr_uarts, 2969 "%d ports, IRQ sharing %sabled\n", nr_uarts,
2970 share_irqs ? "en" : "dis"); 2970 share_irqs ? "en" : "dis");
2971 2971
2972 for (i = 0; i < NR_IRQS; i++)
2973 spin_lock_init(&irq_lists[i].lock);
2974
2972#ifdef CONFIG_SPARC 2975#ifdef CONFIG_SPARC
2973 ret = sunserial_register_minors(&serial8250_reg, UART_NR); 2976 ret = sunserial_register_minors(&serial8250_reg, UART_NR);
2974#else 2977#else
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 9cbff84b787d..da91bb16da8a 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -1855,8 +1855,6 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1855 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; 1855 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1856 struct display *p = &fb_display[vc->vc_num]; 1856 struct display *p = &fb_display[vc->vc_num];
1857 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; 1857 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
1858 unsigned short saved_ec;
1859 int ret;
1860 1858
1861 if (fbcon_is_inactive(vc, info)) 1859 if (fbcon_is_inactive(vc, info))
1862 return -EINVAL; 1860 return -EINVAL;
@@ -1869,11 +1867,6 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1869 * whole screen (prevents flicker). 1867 * whole screen (prevents flicker).
1870 */ 1868 */
1871 1869
1872 saved_ec = vc->vc_video_erase_char;
1873 vc->vc_video_erase_char = vc->vc_scrl_erase_char;
1874
1875 ret = 0;
1876
1877 switch (dir) { 1870 switch (dir) {
1878 case SM_UP: 1871 case SM_UP:
1879 if (count > vc->vc_rows) /* Maximum realistic size */ 1872 if (count > vc->vc_rows) /* Maximum realistic size */
@@ -1890,9 +1883,9 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1890 scr_memsetw((unsigned short *) (vc->vc_origin + 1883 scr_memsetw((unsigned short *) (vc->vc_origin +
1891 vc->vc_size_row * 1884 vc->vc_size_row *
1892 (b - count)), 1885 (b - count)),
1893 vc->vc_scrl_erase_char, 1886 vc->vc_video_erase_char,
1894 vc->vc_size_row * count); 1887 vc->vc_size_row * count);
1895 ret = 1; 1888 return 1;
1896 break; 1889 break;
1897 1890
1898 case SCROLL_WRAP_MOVE: 1891 case SCROLL_WRAP_MOVE:
@@ -1962,10 +1955,9 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1962 scr_memsetw((unsigned short *) (vc->vc_origin + 1955 scr_memsetw((unsigned short *) (vc->vc_origin +
1963 vc->vc_size_row * 1956 vc->vc_size_row *
1964 (b - count)), 1957 (b - count)),
1965 vc->vc_scrl_erase_char, 1958 vc->vc_video_erase_char,
1966 vc->vc_size_row * count); 1959 vc->vc_size_row * count);
1967 ret = 1; 1960 return 1;
1968 break;
1969 } 1961 }
1970 break; 1962 break;
1971 1963
@@ -1982,9 +1974,9 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1982 scr_memsetw((unsigned short *) (vc->vc_origin + 1974 scr_memsetw((unsigned short *) (vc->vc_origin +
1983 vc->vc_size_row * 1975 vc->vc_size_row *
1984 t), 1976 t),
1985 vc->vc_scrl_erase_char, 1977 vc->vc_video_erase_char,
1986 vc->vc_size_row * count); 1978 vc->vc_size_row * count);
1987 ret = 1; 1979 return 1;
1988 break; 1980 break;
1989 1981
1990 case SCROLL_WRAP_MOVE: 1982 case SCROLL_WRAP_MOVE:
@@ -2052,15 +2044,12 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
2052 scr_memsetw((unsigned short *) (vc->vc_origin + 2044 scr_memsetw((unsigned short *) (vc->vc_origin +
2053 vc->vc_size_row * 2045 vc->vc_size_row *
2054 t), 2046 t),
2055 vc->vc_scrl_erase_char, 2047 vc->vc_video_erase_char,
2056 vc->vc_size_row * count); 2048 vc->vc_size_row * count);
2057 ret = 1; 2049 return 1;
2058 break;
2059 } 2050 }
2060 break;
2061 } 2051 }
2062 vc->vc_video_erase_char = saved_ec; 2052 return 0;
2063 return ret;
2064} 2053}
2065 2054
2066 2055
@@ -2522,9 +2511,6 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2522 c = vc->vc_video_erase_char; 2511 c = vc->vc_video_erase_char;
2523 vc->vc_video_erase_char = 2512 vc->vc_video_erase_char =
2524 ((c & 0xfe00) >> 1) | (c & 0xff); 2513 ((c & 0xfe00) >> 1) | (c & 0xff);
2525 c = vc->vc_scrl_erase_char;
2526 vc->vc_scrl_erase_char =
2527 ((c & 0xFE00) >> 1) | (c & 0xFF);
2528 vc->vc_attr >>= 1; 2514 vc->vc_attr >>= 1;
2529 } 2515 }
2530 } else if (!vc->vc_hi_font_mask && cnt == 512) { 2516 } else if (!vc->vc_hi_font_mask && cnt == 512) {
@@ -2555,14 +2541,9 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2555 if (vc->vc_can_do_color) { 2541 if (vc->vc_can_do_color) {
2556 vc->vc_video_erase_char = 2542 vc->vc_video_erase_char =
2557 ((c & 0xff00) << 1) | (c & 0xff); 2543 ((c & 0xff00) << 1) | (c & 0xff);
2558 c = vc->vc_scrl_erase_char;
2559 vc->vc_scrl_erase_char =
2560 ((c & 0xFF00) << 1) | (c & 0xFF);
2561 vc->vc_attr <<= 1; 2544 vc->vc_attr <<= 1;
2562 } else { 2545 } else
2563 vc->vc_video_erase_char = c & ~0x100; 2546 vc->vc_video_erase_char = c & ~0x100;
2564 vc->vc_scrl_erase_char = c & ~0x100;
2565 }
2566 } 2547 }
2567 2548
2568 } 2549 }
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index 9901064199bd..dd3eaaad4441 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -533,7 +533,7 @@ static void mdacon_cursor(struct vc_data *c, int mode)
533 533
534static int mdacon_scroll(struct vc_data *c, int t, int b, int dir, int lines) 534static int mdacon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
535{ 535{
536 u16 eattr = mda_convert_attr(c->vc_scrl_erase_char); 536 u16 eattr = mda_convert_attr(c->vc_video_erase_char);
537 537
538 if (!lines) 538 if (!lines)
539 return 0; 539 return 0;
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 4055dbdd1b42..491c1c1baf4c 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -170,12 +170,12 @@ static int sticon_scroll(struct vc_data *conp, int t, int b, int dir, int count)
170 switch (dir) { 170 switch (dir) {
171 case SM_UP: 171 case SM_UP:
172 sti_bmove(sti, t + count, 0, t, 0, b - t - count, conp->vc_cols); 172 sti_bmove(sti, t + count, 0, t, 0, b - t - count, conp->vc_cols);
173 sti_clear(sti, b - count, 0, count, conp->vc_cols, conp->vc_scrl_erase_char); 173 sti_clear(sti, b - count, 0, count, conp->vc_cols, conp->vc_video_erase_char);
174 break; 174 break;
175 175
176 case SM_DOWN: 176 case SM_DOWN:
177 sti_bmove(sti, t, 0, t + count, 0, b - t - count, conp->vc_cols); 177 sti_bmove(sti, t, 0, t + count, 0, b - t - count, conp->vc_cols);
178 sti_clear(sti, t, 0, count, conp->vc_cols, conp->vc_scrl_erase_char); 178 sti_clear(sti, t, 0, count, conp->vc_cols, conp->vc_video_erase_char);
179 break; 179 break;
180 } 180 }
181 181
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index bd1f57b259d9..6df29a62d720 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -1350,7 +1350,7 @@ static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
1350 } else 1350 } else
1351 c->vc_origin += delta; 1351 c->vc_origin += delta;
1352 scr_memsetw((u16 *) (c->vc_origin + c->vc_screenbuf_size - 1352 scr_memsetw((u16 *) (c->vc_origin + c->vc_screenbuf_size -
1353 delta), c->vc_scrl_erase_char, 1353 delta), c->vc_video_erase_char,
1354 delta); 1354 delta);
1355 } else { 1355 } else {
1356 if (oldo - delta < vga_vram_base) { 1356 if (oldo - delta < vga_vram_base) {
@@ -1363,7 +1363,7 @@ static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
1363 } else 1363 } else
1364 c->vc_origin -= delta; 1364 c->vc_origin -= delta;
1365 c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; 1365 c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size;
1366 scr_memsetw((u16 *) (c->vc_origin), c->vc_scrl_erase_char, 1366 scr_memsetw((u16 *) (c->vc_origin), c->vc_video_erase_char,
1367 delta); 1367 delta);
1368 } 1368 }
1369 c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; 1369 c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size;