1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2008 Sensoray Company Inc.
6 #include <linux/module.h>
7 #include <linux/slab.h>
9 #include <linux/firmware.h>
10 #include <cypress_firmware.h>
15 const char * const fw_name1
;
16 const char * const fw_name2
;
19 static struct fw_config fw_configs
[] = {
20 { 0x1943, 0xa250, "go7007/s2250-1.fw", "go7007/s2250-2.fw" },
21 { 0x093b, 0xa002, "go7007/px-m402u.fw", NULL
},
22 { 0x093b, 0xa004, "go7007/px-tv402u.fw", NULL
},
23 { 0x0eb1, 0x6666, "go7007/lr192.fw", NULL
},
24 { 0x0eb1, 0x6668, "go7007/wis-startrek.fw", NULL
},
27 MODULE_FIRMWARE("go7007/s2250-1.fw");
28 MODULE_FIRMWARE("go7007/s2250-2.fw");
29 MODULE_FIRMWARE("go7007/px-m402u.fw");
30 MODULE_FIRMWARE("go7007/px-tv402u.fw");
31 MODULE_FIRMWARE("go7007/lr192.fw");
32 MODULE_FIRMWARE("go7007/wis-startrek.fw");
34 static int go7007_loader_probe(struct usb_interface
*interface
,
35 const struct usb_device_id
*id
)
37 struct usb_device
*usbdev
;
38 const struct firmware
*fw
;
40 const char *fw1
, *fw2
;
44 usbdev
= usb_get_dev(interface_to_usbdev(interface
));
48 if (usbdev
->descriptor
.bNumConfigurations
!= 1) {
49 dev_err(&interface
->dev
, "can't handle multiple config\n");
53 vendor
= le16_to_cpu(usbdev
->descriptor
.idVendor
);
54 product
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
56 for (i
= 0; fw_configs
[i
].fw_name1
; i
++)
57 if (fw_configs
[i
].vendor
== vendor
&&
58 fw_configs
[i
].product
== product
)
61 /* Should never happen */
62 if (fw_configs
[i
].fw_name1
== NULL
)
65 fw1
= fw_configs
[i
].fw_name1
;
66 fw2
= fw_configs
[i
].fw_name2
;
68 dev_info(&interface
->dev
, "loading firmware %s\n", fw1
);
70 if (request_firmware(&fw
, fw1
, &usbdev
->dev
)) {
71 dev_err(&interface
->dev
,
72 "unable to load firmware from file \"%s\"\n", fw1
);
75 ret
= cypress_load_firmware(usbdev
, fw
, CYPRESS_FX2
);
78 dev_err(&interface
->dev
, "loader download failed\n");
85 if (request_firmware(&fw
, fw2
, &usbdev
->dev
)) {
86 dev_err(&interface
->dev
,
87 "unable to load firmware from file \"%s\"\n", fw2
);
90 ret
= cypress_load_firmware(usbdev
, fw
, CYPRESS_FX2
);
93 dev_err(&interface
->dev
, "firmware download failed\n");
100 dev_err(&interface
->dev
, "probe failed\n");
104 static void go7007_loader_disconnect(struct usb_interface
*interface
)
106 dev_info(&interface
->dev
, "disconnect\n");
107 usb_put_dev(interface_to_usbdev(interface
));
108 usb_set_intfdata(interface
, NULL
);
111 static const struct usb_device_id go7007_loader_ids
[] = {
112 { USB_DEVICE(0x1943, 0xa250) },
113 { USB_DEVICE(0x093b, 0xa002) },
114 { USB_DEVICE(0x093b, 0xa004) },
115 { USB_DEVICE(0x0eb1, 0x6666) },
116 { USB_DEVICE(0x0eb1, 0x6668) },
117 {} /* Terminating entry */
120 MODULE_DEVICE_TABLE(usb
, go7007_loader_ids
);
122 static struct usb_driver go7007_loader_driver
= {
123 .name
= "go7007-loader",
124 .probe
= go7007_loader_probe
,
125 .disconnect
= go7007_loader_disconnect
,
126 .id_table
= go7007_loader_ids
,
129 module_usb_driver(go7007_loader_driver
);
132 MODULE_DESCRIPTION("firmware loader for go7007-usb");
133 MODULE_LICENSE("GPL v2");