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, "/*(DEBLOBBED)*/", "/*(DEBLOBBED)*/" },
29 { 0x093b, 0xa002, "/*(DEBLOBBED)*/", NULL },
30 { 0x093b, 0xa004, "/*(DEBLOBBED)*/", NULL },
31 { 0x0eb1, 0x6666, "/*(DEBLOBBED)*/", NULL },
32 { 0x0eb1, 0x6668, "/*(DEBLOBBED)*/", NULL },
37 static int go7007_loader_probe(struct usb_interface *interface,
38 const struct usb_device_id *id)
40 struct usb_device *usbdev;
41 const struct firmware *fw;
43 const char *fw1, *fw2;
47 usbdev = usb_get_dev(interface_to_usbdev(interface));
51 if (usbdev->descriptor.bNumConfigurations != 1) {
52 dev_err(&interface->dev, "can't handle multiple config\n");
56 vendor = le16_to_cpu(usbdev->descriptor.idVendor);
57 product = le16_to_cpu(usbdev->descriptor.idProduct);
59 for (i = 0; fw_configs[i].fw_name1; i++)
60 if (fw_configs[i].vendor == vendor &&
61 fw_configs[i].product == product)
64 /* Should never happen */
65 if (fw_configs[i].fw_name1 == NULL)
68 fw1 = fw_configs[i].fw_name1;
69 fw2 = fw_configs[i].fw_name2;
71 dev_info(&interface->dev, "loading firmware %s\n", fw1);
73 if (reject_firmware(&fw, fw1, &usbdev->dev)) {
74 dev_err(&interface->dev,
75 "unable to load firmware from file \"%s\"\n", fw1);
78 ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
81 dev_err(&interface->dev, "loader download failed\n");
88 if (reject_firmware(&fw, fw2, &usbdev->dev)) {
89 dev_err(&interface->dev,
90 "unable to load firmware from file \"%s\"\n", fw2);
93 ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
96 dev_err(&interface->dev, "firmware download failed\n");
103 dev_err(&interface->dev, "probe failed\n");
107 static void go7007_loader_disconnect(struct usb_interface *interface)
109 dev_info(&interface->dev, "disconnect\n");
110 usb_put_dev(interface_to_usbdev(interface));
111 usb_set_intfdata(interface, NULL);
114 static const struct usb_device_id go7007_loader_ids[] = {
115 { USB_DEVICE(0x1943, 0xa250) },
116 { USB_DEVICE(0x093b, 0xa002) },
117 { USB_DEVICE(0x093b, 0xa004) },
118 { USB_DEVICE(0x0eb1, 0x6666) },
119 { USB_DEVICE(0x0eb1, 0x6668) },
120 {} /* Terminating entry */
123 MODULE_DEVICE_TABLE(usb, go7007_loader_ids);
125 static struct usb_driver go7007_loader_driver = {
126 .name = "go7007-loader",
127 .probe = go7007_loader_probe,
128 .disconnect = go7007_loader_disconnect,
129 .id_table = go7007_loader_ids,
132 module_usb_driver(go7007_loader_driver);
135 MODULE_DESCRIPTION("firmware loader for go7007-usb");
136 MODULE_LICENSE("GPL v2");