2 * Copyright (C) 2008 Sensoray Company Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/usb.h>
17 #include <linux/firmware.h>
18 #include <cypress_firmware.h>
23 const char * const fw_name1
;
24 const char * const fw_name2
;
27 static struct fw_config fw_configs
[] = {
28 { 0x1943, 0xa250, "go7007/s2250-1.fw", "go7007/s2250-2.fw" },
29 { 0x093b, 0xa002, "go7007/px-m402u.fw", NULL
},
30 { 0x093b, 0xa004, "go7007/px-tv402u.fw", NULL
},
31 { 0x0eb1, 0x6666, "go7007/lr192.fw", NULL
},
32 { 0x0eb1, 0x6668, "go7007/wis-startrek.fw", NULL
},
35 MODULE_FIRMWARE("go7007/s2250-1.fw");
36 MODULE_FIRMWARE("go7007/s2250-2.fw");
37 MODULE_FIRMWARE("go7007/px-m402u.fw");
38 MODULE_FIRMWARE("go7007/px-tv402u.fw");
39 MODULE_FIRMWARE("go7007/lr192.fw");
40 MODULE_FIRMWARE("go7007/wis-startrek.fw");
42 static int go7007_loader_probe(struct usb_interface
*interface
,
43 const struct usb_device_id
*id
)
45 struct usb_device
*usbdev
;
46 const struct firmware
*fw
;
48 const char *fw1
, *fw2
;
52 usbdev
= usb_get_dev(interface_to_usbdev(interface
));
56 if (usbdev
->descriptor
.bNumConfigurations
!= 1) {
57 dev_err(&interface
->dev
, "can't handle multiple config\n");
61 vendor
= le16_to_cpu(usbdev
->descriptor
.idVendor
);
62 product
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
64 for (i
= 0; fw_configs
[i
].fw_name1
; i
++)
65 if (fw_configs
[i
].vendor
== vendor
&&
66 fw_configs
[i
].product
== product
)
69 /* Should never happen */
70 if (fw_configs
[i
].fw_name1
== NULL
)
73 fw1
= fw_configs
[i
].fw_name1
;
74 fw2
= fw_configs
[i
].fw_name2
;
76 dev_info(&interface
->dev
, "loading firmware %s\n", fw1
);
78 if (request_firmware(&fw
, fw1
, &usbdev
->dev
)) {
79 dev_err(&interface
->dev
,
80 "unable to load firmware from file \"%s\"\n", fw1
);
83 ret
= cypress_load_firmware(usbdev
, fw
, CYPRESS_FX2
);
86 dev_err(&interface
->dev
, "loader download failed\n");
93 if (request_firmware(&fw
, fw2
, &usbdev
->dev
)) {
94 dev_err(&interface
->dev
,
95 "unable to load firmware from file \"%s\"\n", fw2
);
98 ret
= cypress_load_firmware(usbdev
, fw
, CYPRESS_FX2
);
101 dev_err(&interface
->dev
, "firmware download failed\n");
108 dev_err(&interface
->dev
, "probe failed\n");
112 static void go7007_loader_disconnect(struct usb_interface
*interface
)
114 dev_info(&interface
->dev
, "disconnect\n");
115 usb_put_dev(interface_to_usbdev(interface
));
116 usb_set_intfdata(interface
, NULL
);
119 static const struct usb_device_id go7007_loader_ids
[] = {
120 { USB_DEVICE(0x1943, 0xa250) },
121 { USB_DEVICE(0x093b, 0xa002) },
122 { USB_DEVICE(0x093b, 0xa004) },
123 { USB_DEVICE(0x0eb1, 0x6666) },
124 { USB_DEVICE(0x0eb1, 0x6668) },
125 {} /* Terminating entry */
128 MODULE_DEVICE_TABLE(usb
, go7007_loader_ids
);
130 static struct usb_driver go7007_loader_driver
= {
131 .name
= "go7007-loader",
132 .probe
= go7007_loader_probe
,
133 .disconnect
= go7007_loader_disconnect
,
134 .id_table
= go7007_loader_ids
,
137 module_usb_driver(go7007_loader_driver
);
140 MODULE_DESCRIPTION("firmware loader for go7007-usb");
141 MODULE_LICENSE("GPL v2");