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.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 #include <linux/module.h>
19 #include <linux/slab.h>
20 #include <linux/usb.h>
21 #include <linux/firmware.h>
22 #include <cypress_firmware.h>
27 const char * const fw_name1
;
28 const char * const fw_name2
;
31 struct fw_config fw_configs
[] = {
32 { 0x1943, 0xa250, "go7007/s2250-1.fw", "go7007/s2250-2.fw" },
33 { 0x093b, 0xa002, "go7007/px-m402u.fw", NULL
},
34 { 0x093b, 0xa004, "go7007/px-tv402u.fw", NULL
},
35 { 0x0eb1, 0x6666, "go7007/lr192.fw", NULL
},
36 { 0x0eb1, 0x6668, "go7007/wis-startrek.fw", NULL
},
39 MODULE_FIRMWARE("go7007/s2250-1.fw");
40 MODULE_FIRMWARE("go7007/s2250-2.fw");
41 MODULE_FIRMWARE("go7007/px-m402u.fw");
42 MODULE_FIRMWARE("go7007/px-tv402u.fw");
43 MODULE_FIRMWARE("go7007/lr192.fw");
44 MODULE_FIRMWARE("go7007/wis-startrek.fw");
46 static int go7007_loader_probe(struct usb_interface
*interface
,
47 const struct usb_device_id
*id
)
49 struct usb_device
*usbdev
;
50 const struct firmware
*fw
;
52 const char *fw1
, *fw2
;
56 usbdev
= usb_get_dev(interface_to_usbdev(interface
));
60 if (usbdev
->descriptor
.bNumConfigurations
!= 1) {
61 dev_err(&interface
->dev
, "can't handle multiple config\n");
65 vendor
= le16_to_cpu(usbdev
->descriptor
.idVendor
);
66 product
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
68 for (i
= 0; fw_configs
[i
].fw_name1
; i
++)
69 if (fw_configs
[i
].vendor
== vendor
&&
70 fw_configs
[i
].product
== product
)
73 /* Should never happen */
74 if (fw_configs
[i
].fw_name1
== NULL
)
77 fw1
= fw_configs
[i
].fw_name1
;
78 fw2
= fw_configs
[i
].fw_name2
;
80 dev_info(&interface
->dev
, "loading firmware %s\n", fw1
);
82 if (request_firmware(&fw
, fw1
, &usbdev
->dev
)) {
83 dev_err(&interface
->dev
,
84 "unable to load firmware from file \"%s\"\n", fw1
);
87 ret
= cypress_load_firmware(usbdev
, fw
, CYPRESS_FX2
);
90 dev_err(&interface
->dev
, "loader download failed\n");
97 if (request_firmware(&fw
, fw2
, &usbdev
->dev
)) {
98 dev_err(&interface
->dev
,
99 "unable to load firmware from file \"%s\"\n", fw2
);
102 ret
= cypress_load_firmware(usbdev
, fw
, CYPRESS_FX2
);
103 release_firmware(fw
);
105 dev_err(&interface
->dev
, "firmware download failed\n");
111 dev_err(&interface
->dev
, "probe failed\n");
115 static void go7007_loader_disconnect(struct usb_interface
*interface
)
117 dev_info(&interface
->dev
, "disconnect\n");
118 usb_set_intfdata(interface
, NULL
);
121 static const struct usb_device_id go7007_loader_ids
[] = {
122 { USB_DEVICE(0x1943, 0xa250) },
123 { USB_DEVICE(0x093b, 0xa002) },
124 { USB_DEVICE(0x093b, 0xa004) },
125 { USB_DEVICE(0x0eb1, 0x6666) },
126 { USB_DEVICE(0x0eb1, 0x6668) },
127 {} /* Terminating entry */
130 MODULE_DEVICE_TABLE(usb
, go7007_loader_ids
);
132 static struct usb_driver go7007_loader_driver
= {
133 .name
= "go7007-loader",
134 .probe
= go7007_loader_probe
,
135 .disconnect
= go7007_loader_disconnect
,
136 .id_table
= go7007_loader_ids
,
139 module_usb_driver(go7007_loader_driver
);
142 MODULE_DESCRIPTION("firmware loader for go7007-usb");
143 MODULE_LICENSE("GPL v2");