27 #include <linux/kernel.h>
28 #include <linux/errno.h>
30 #include <linux/slab.h>
31 #include <linux/module.h>
35 #include <linux/ctype.h>
36 #include <linux/string.h>
37 #include <linux/types.h>
43 #define VENDOR_ID 0x1B24
44 #define PRODUCT_ID 0x4001
56 #define TLG2300_FIRMWARE "tlg2300_firmware.bin"
58 static struct usb_driver poseidon_driver;
68 u16 lower_16, upper_16;
76 upper_16 = lower_16 = 0;
79 lower_16 = (
unsigned short)(param & 0xffff);
80 upper_16 = (
unsigned short)((param >> 16) & 0xffff);
83 usb_rcvctrlpipe(pd->
udev, 0),
90 USB_CTRL_GET_TIMEOUT);
96 memcpy((
char *)cmd_status, &(data[0]),
sizeof(*cmd_status));
109 u16 lower_16, upper_16;
116 upper_16 = lower_16 = 0;
119 lower_16 = (
unsigned short)(param & 0xffff);
120 upper_16 = (
unsigned short)((param >> 16) & 0xffff);
123 usb_rcvctrlpipe(pd->
udev, 0),
129 (datalen +
sizeof(*cmd_status)),
130 USB_CTRL_GET_TIMEOUT);
136 memcpy((
char *)cmd_status, &data[0],
sizeof(*cmd_status));
137 memcpy((
char *)buf, &data[
sizeof(*cmd_status)], datalen);
151 struct usb_device *
udev;
163 usb_unlock_device(udev);
170 log(
"event :%ld\n", event);
175 .notifier_call = pm_notifier_block,
186 if (ret || cmd_status)
214 static int firmware_download(
struct usb_device *
udev)
216 int ret = 0, actual_length;
219 size_t fwlength = 0,
offset;
220 size_t max_packet_size;
224 log(
"download err : %d", ret);
236 max_packet_size = udev->ep_out[0x1]->desc.wMaxPacketSize;
237 log(
"\t\t download size : %d", (
int)max_packet_size);
242 usb_sndbulkpipe(udev, 0x01),
258 return usb_get_intfdata(intf);
263 static inline void set_map_flags(
struct poseidon *pd,
struct usb_device *udev)
265 pd->portnum = udev->portnum;
268 static inline int get_autopm_ref(
struct poseidon *pd)
280 count = get_autopm_ref(pd);
288 log(
"event : %d\n", pd->msg.event);
292 static struct poseidon *find_old_poseidon(
struct usb_device *udev)
304 static inline int is_working(
struct poseidon *pd)
315 if (!is_working(pd)) {
318 pd->pm_resume =
NULL;
325 return pd->pm_suspend ? pd->pm_suspend(pd) : 0;
336 if (!is_working(pd)) {
346 return pd->pm_resume ? pd->pm_resume(pd) : 0;
358 count = get_autopm_ref(pd);
368 static inline struct poseidon *find_old_poseidon(
struct usb_device *udev)
373 static inline void set_map_flags(
struct poseidon *pd,
struct usb_device *udev)
378 static int check_firmware(
struct usb_device *udev,
int *down_firmware)
388 usb_rcvctrlpipe(udev, 0),
394 sizeof(*cmd_firm) +
sizeof(
u32),
395 USB_CTRL_GET_TIMEOUT);
400 return firmware_download(udev);
408 struct usb_device *udev = interface_to_usbdev(interface);
414 check_firmware(udev, &ret);
419 pd = find_old_poseidon(udev);
424 kref_init(&pd->
kref);
425 set_map_flags(pd, udev);
431 usb_set_intfdata(interface, pd);
441 dev->
driver->name, dev_name(dev));
458 usb_enable_autosuspend(pd->
udev);
461 INIT_WORK(&pd->pm_work, hibernation_resume);
468 static void poseidon_disconnect(
struct usb_interface *interface)
470 struct poseidon *pd = get_pd(interface);
495 usb_set_intfdata(interface,
NULL);
499 static struct usb_driver poseidon_driver = {
501 .probe = poseidon_probe,
502 .disconnect = poseidon_disconnect,
503 .id_table = id_table,
505 .suspend = poseidon_suspend,
506 .resume = poseidon_resume,
508 .supports_autosuspend = 1,
511 static int __init poseidon_init(
void)
515 ret = usb_register(&poseidon_driver);
518 register_pm_notifier(&pm_notifer);
522 static void __exit poseidon_exit(
void)
525 unregister_pm_notifier(&pm_notifer);