Lines Matching +full:en +full:- +full:modem
1 // SPDX-License-Identifier: GPL-2.0+
3 * speedtch.c - Alcatel SpeedTouch USB xDSL modem driver
146 struct usbatm_data *usbatm = instance->usbatm; in speedtch_set_swbuff()
147 struct usb_device *usb_dev = usbatm->usb_dev; in speedtch_set_swbuff()
155 state ? "En" : "Dis", ret); in speedtch_set_swbuff()
157 usb_dbg(usbatm, "speedtch_set_swbuff: %sbled SW buffering\n", state ? "En" : "Dis"); in speedtch_set_swbuff()
162 struct usbatm_data *usbatm = instance->usbatm; in speedtch_test_sequence()
163 struct usb_device *usb_dev = usbatm->usb_dev; in speedtch_test_sequence()
164 unsigned char *buf = instance->scratch_buffer; in speedtch_test_sequence()
201 /* Extra initialisation in recent drivers - gives higher speeds */ in speedtch_test_sequence()
204 buf[0] = instance->params.ModemMode; in speedtch_test_sequence()
212 rate -- it does require the new firmware too, although it works OK in speedtch_test_sequence()
216 instance->params.ModemOption, in speedtch_test_sequence()
222 buf[0] = instance->params.BMaxDSL & 0xff; in speedtch_test_sequence()
223 buf[1] = instance->params.BMaxDSL >> 8; in speedtch_test_sequence()
235 struct usbatm_data *usbatm = instance->usbatm; in speedtch_upload_firmware()
236 struct usb_device *usb_dev = usbatm->usb_dev; in speedtch_upload_firmware()
245 ret = -ENOMEM; in speedtch_upload_firmware()
251 ret = -ENODEV; in speedtch_upload_firmware()
261 if (ret < 0 && ret != -ETIMEDOUT) in speedtch_upload_firmware()
262 usb_warn(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret); in speedtch_upload_firmware()
268 for (offset = 0; offset < fw1->size; offset += PAGE_SIZE) { in speedtch_upload_firmware()
269 int thislen = min_t(int, PAGE_SIZE, fw1->size - offset); in speedtch_upload_firmware()
270 memcpy(buffer, fw1->data + offset, thislen); in speedtch_upload_firmware()
276 usb_err(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret); in speedtch_upload_firmware()
279 usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size); in speedtch_upload_firmware()
289 usb_err(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret); in speedtch_upload_firmware()
294 /* URBs 12 to 139 - USB led blinking green, ADSL led off */ in speedtch_upload_firmware()
295 for (offset = 0; offset < fw2->size; offset += PAGE_SIZE) { in speedtch_upload_firmware()
296 int thislen = min_t(int, PAGE_SIZE, fw2->size - offset); in speedtch_upload_firmware()
297 memcpy(buffer, fw2->data + offset, thislen); in speedtch_upload_firmware()
303 usb_err(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret); in speedtch_upload_firmware()
307 usb_dbg(usbatm, "%s: BLOCK3 uploaded (%zu bytes)\n", __func__, fw2->size); in speedtch_upload_firmware()
316 usb_err(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret); in speedtch_upload_firmware()
327 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) { in speedtch_upload_firmware()
328 …usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->params.altsettin… in speedtch_upload_firmware()
350 struct device *dev = &intf->dev; in speedtch_find_firmware()
351 const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice); in speedtch_find_firmware()
356 sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision); in speedtch_find_firmware()
360 sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision); in speedtch_find_firmware()
364 sprintf(buf, "speedtch-%d.bin", phase); in speedtch_find_firmware()
369 return -ENOENT; in speedtch_find_firmware()
382 struct speedtch_instance_data *instance = usbatm->driver_data; in speedtch_heavy_init()
409 struct usbatm_data *usbatm = instance->usbatm; in speedtch_read_status()
410 struct usb_device *usb_dev = usbatm->usb_dev; in speedtch_read_status()
411 unsigned char *buf = instance->scratch_buffer; in speedtch_read_status()
461 struct usbatm_data *usbatm = instance->usbatm; in speedtch_start_synchro()
462 struct usb_device *usb_dev = usbatm->usb_dev; in speedtch_start_synchro()
463 unsigned char *buf = instance->scratch_buffer; in speedtch_start_synchro()
477 atm_dbg(usbatm, "%s: modem prodded. %d bytes returned: %02x %02x\n", in speedtch_start_synchro()
488 struct usbatm_data *usbatm = instance->usbatm; in speedtch_check_status()
489 struct atm_dev *atm_dev = usbatm->atm_dev; in speedtch_check_status()
490 unsigned char *buf = instance->scratch_buffer; in speedtch_check_status()
501 instance->poll_delay = min(2 * instance->poll_delay, MAX_POLL_DELAY); in speedtch_check_status()
505 instance->poll_delay = max(instance->poll_delay / 2, MIN_POLL_DELAY); in speedtch_check_status()
509 if ((status != instance->last_status) || !status) { in speedtch_check_status()
515 if (instance->last_status) in speedtch_check_status()
542 atm_dev->link_rate = down_speed * 1000 / 424; in speedtch_check_status()
556 instance->last_status = status; in speedtch_check_status()
566 schedule_work(&instance->status_check_work); in speedtch_status_poll()
569 if (instance->poll_delay < MAX_POLL_DELAY) in speedtch_status_poll()
570 mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(instance->poll_delay)); in speedtch_status_poll()
572 atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n"); in speedtch_status_poll()
580 struct urb *int_urb = instance->int_urb; in speedtch_resubmit_int()
583 atm_dbg(instance->usbatm, "%s entered\n", __func__); in speedtch_resubmit_int()
588 schedule_work(&instance->status_check_work); in speedtch_resubmit_int()
590 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); in speedtch_resubmit_int()
591 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); in speedtch_resubmit_int()
598 struct speedtch_instance_data *instance = int_urb->context; in speedtch_handle_int()
599 struct usbatm_data *usbatm = instance->usbatm; in speedtch_handle_int()
600 unsigned int count = int_urb->actual_length; in speedtch_handle_int()
601 int status = int_urb->status; in speedtch_handle_int()
616 if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) { in speedtch_handle_int()
617 timer_delete(&instance->status_check_timer); in speedtch_handle_int()
619 } else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) { in speedtch_handle_int()
626 printk(" %02x", instance->int_data[i]); in speedtch_handle_int()
631 int_urb = instance->int_urb; in speedtch_handle_int()
634 schedule_work(&instance->status_check_work); in speedtch_handle_int()
644 int_urb = instance->int_urb; in speedtch_handle_int()
646 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); in speedtch_handle_int()
651 struct usb_device *usb_dev = usbatm->usb_dev; in speedtch_atm_start()
652 struct speedtch_instance_data *instance = usbatm->driver_data; in speedtch_atm_start()
659 memset(atm_dev->esi, 0, sizeof(atm_dev->esi)); in speedtch_atm_start()
660 if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) { in speedtch_atm_start()
662 atm_dev->esi[i] = (hex_to_bin(mac_str[i * 2]) << 4) + in speedtch_atm_start()
666 /* Start modem synchronisation */ in speedtch_atm_start()
670 if (instance->int_urb) { in speedtch_atm_start()
671 ret = usb_submit_urb(instance->int_urb, GFP_KERNEL); in speedtch_atm_start()
675 usb_free_urb(instance->int_urb); in speedtch_atm_start()
676 instance->int_urb = NULL; in speedtch_atm_start()
681 mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(1000)); in speedtch_atm_start()
688 struct speedtch_instance_data *instance = usbatm->driver_data; in speedtch_atm_stop()
689 struct urb *int_urb = instance->int_urb; in speedtch_atm_stop()
693 timer_delete_sync(&instance->status_check_timer); in speedtch_atm_stop()
699 instance->int_urb = NULL; /* signal shutdown */ in speedtch_atm_stop()
702 timer_delete_sync(&instance->resubmit_timer); in speedtch_atm_stop()
705 * can run or be running, but instance->int_urb == NULL means that in speedtch_atm_stop()
709 timer_delete_sync(&instance->resubmit_timer); in speedtch_atm_stop()
712 flush_work(&instance->status_check_work); in speedtch_atm_stop()
770 int ifnum = intf->altsetting->desc.bInterfaceNumber; in speedtch_bind()
771 int num_interfaces = usb_dev->actconfig->desc.bNumInterfaces; in speedtch_bind()
779 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { in speedtch_bind()
780 usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass); in speedtch_bind()
781 return -ENODEV; in speedtch_bind()
787 return -ENODEV; in speedtch_bind()
809 ret = -ENOMEM; in speedtch_bind()
813 instance->usbatm = usbatm; in speedtch_bind()
816 instance->params.altsetting = altsetting; in speedtch_bind()
817 instance->params.BMaxDSL = BMaxDSL; in speedtch_bind()
818 instance->params.ModemMode = ModemMode; in speedtch_bind()
819 memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH); in speedtch_bind()
820 memcpy(instance->params.ModemOption, ModemOption, num_ModemOption); in speedtch_bind()
823 if (instance->params.altsetting) in speedtch_bind()
824 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) { in speedtch_bind()
825 …usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetti… in speedtch_bind()
826 instance->params.altsetting = 0; /* fall back to default */ in speedtch_bind()
829 if (!instance->params.altsetting && use_isoc) in speedtch_bind()
836 const struct usb_host_interface *desc = data_intf->cur_altsetting; in speedtch_bind()
837 const __u8 target_address = USB_DIR_IN | usbatm->driver->isoc_in; in speedtch_bind()
841 for (i = 0; i < desc->desc.bNumEndpoints; i++) { in speedtch_bind()
842 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; in speedtch_bind()
844 if ((endpoint_desc->bEndpointAddress == target_address)) { in speedtch_bind()
852 usb_info(usbatm, "isochronous transfer not supported - using bulk\n"); in speedtch_bind()
855 if (!use_isoc && !instance->params.altsetting) in speedtch_bind()
861 if (!instance->params.altsetting) in speedtch_bind()
862 instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING; in speedtch_bind()
864 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); in speedtch_bind()
866 INIT_WORK(&instance->status_check_work, speedtch_check_status); in speedtch_bind()
867 timer_setup(&instance->status_check_timer, speedtch_status_poll, 0); in speedtch_bind()
868 instance->last_status = 0xff; in speedtch_bind()
869 instance->poll_delay = MIN_POLL_DELAY; in speedtch_bind()
871 timer_setup(&instance->resubmit_timer, speedtch_resubmit_int, 0); in speedtch_bind()
873 instance->int_urb = usb_alloc_urb(0, GFP_KERNEL); in speedtch_bind()
875 if (instance->int_urb) in speedtch_bind()
876 usb_fill_int_urb(instance->int_urb, usb_dev, in speedtch_bind()
878 instance->int_data, sizeof(instance->int_data), in speedtch_bind()
883 /* check whether the modem already seems to be alive */ in speedtch_bind()
886 instance->scratch_buffer + OFFSET_7, SIZE_7, 500); in speedtch_bind()
888 usbatm->flags |= (ret == SIZE_7 ? UDSL_SKIP_HEAVY_INIT : 0); in speedtch_bind()
890 …usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, usbatm->flags & UDSL_SKIP_HEAVY_INIT ? "alre… in speedtch_bind()
892 if (!(usbatm->flags & UDSL_SKIP_HEAVY_INIT)) in speedtch_bind()
898 usbatm->driver_data = instance; in speedtch_bind()
903 usb_free_urb(instance->int_urb); in speedtch_bind()
913 struct speedtch_instance_data *instance = usbatm->driver_data; in speedtch_unbind()
917 speedtch_release_interfaces(usb_dev, usb_dev->actconfig->desc.bNumInterfaces); in speedtch_unbind()
918 usb_free_urb(instance->int_urb); in speedtch_unbind()