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()
565 schedule_work(&instance->status_check_work); in speedtch_status_poll()
568 if (instance->poll_delay < MAX_POLL_DELAY) in speedtch_status_poll()
569 mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(instance->poll_delay)); in speedtch_status_poll()
571 atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n"); in speedtch_status_poll()
578 struct urb *int_urb = instance->int_urb; in speedtch_resubmit_int()
581 atm_dbg(instance->usbatm, "%s entered\n", __func__); in speedtch_resubmit_int()
586 schedule_work(&instance->status_check_work); in speedtch_resubmit_int()
588 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); in speedtch_resubmit_int()
589 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); in speedtch_resubmit_int()
596 struct speedtch_instance_data *instance = int_urb->context; in speedtch_handle_int()
597 struct usbatm_data *usbatm = instance->usbatm; in speedtch_handle_int()
598 unsigned int count = int_urb->actual_length; in speedtch_handle_int()
599 int status = int_urb->status; in speedtch_handle_int()
614 if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) { in speedtch_handle_int()
615 del_timer(&instance->status_check_timer); in speedtch_handle_int()
617 } else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) { in speedtch_handle_int()
624 printk(" %02x", instance->int_data[i]); in speedtch_handle_int()
629 int_urb = instance->int_urb; in speedtch_handle_int()
632 schedule_work(&instance->status_check_work); in speedtch_handle_int()
642 int_urb = instance->int_urb; in speedtch_handle_int()
644 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); in speedtch_handle_int()
649 struct usb_device *usb_dev = usbatm->usb_dev; in speedtch_atm_start()
650 struct speedtch_instance_data *instance = usbatm->driver_data; in speedtch_atm_start()
657 memset(atm_dev->esi, 0, sizeof(atm_dev->esi)); in speedtch_atm_start()
658 if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) { in speedtch_atm_start()
660 atm_dev->esi[i] = (hex_to_bin(mac_str[i * 2]) << 4) + in speedtch_atm_start()
664 /* Start modem synchronisation */ in speedtch_atm_start()
668 if (instance->int_urb) { in speedtch_atm_start()
669 ret = usb_submit_urb(instance->int_urb, GFP_KERNEL); in speedtch_atm_start()
673 usb_free_urb(instance->int_urb); in speedtch_atm_start()
674 instance->int_urb = NULL; in speedtch_atm_start()
679 mod_timer(&instance->status_check_timer, jiffies + msecs_to_jiffies(1000)); in speedtch_atm_start()
686 struct speedtch_instance_data *instance = usbatm->driver_data; in speedtch_atm_stop()
687 struct urb *int_urb = instance->int_urb; in speedtch_atm_stop()
691 del_timer_sync(&instance->status_check_timer); in speedtch_atm_stop()
697 instance->int_urb = NULL; /* signal shutdown */ in speedtch_atm_stop()
700 del_timer_sync(&instance->resubmit_timer); in speedtch_atm_stop()
703 * can run or be running, but instance->int_urb == NULL means that in speedtch_atm_stop()
707 del_timer_sync(&instance->resubmit_timer); in speedtch_atm_stop()
710 flush_work(&instance->status_check_work); in speedtch_atm_stop()
768 int ifnum = intf->altsetting->desc.bInterfaceNumber; in speedtch_bind()
769 int num_interfaces = usb_dev->actconfig->desc.bNumInterfaces; in speedtch_bind()
777 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { in speedtch_bind()
778 usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass); in speedtch_bind()
779 return -ENODEV; in speedtch_bind()
785 return -ENODEV; in speedtch_bind()
807 ret = -ENOMEM; in speedtch_bind()
811 instance->usbatm = usbatm; in speedtch_bind()
814 instance->params.altsetting = altsetting; in speedtch_bind()
815 instance->params.BMaxDSL = BMaxDSL; in speedtch_bind()
816 instance->params.ModemMode = ModemMode; in speedtch_bind()
817 memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH); in speedtch_bind()
818 memcpy(instance->params.ModemOption, ModemOption, num_ModemOption); in speedtch_bind()
821 if (instance->params.altsetting) in speedtch_bind()
822 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) { in speedtch_bind()
823 …usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetti… in speedtch_bind()
824 instance->params.altsetting = 0; /* fall back to default */ in speedtch_bind()
827 if (!instance->params.altsetting && use_isoc) in speedtch_bind()
834 const struct usb_host_interface *desc = data_intf->cur_altsetting; in speedtch_bind()
835 const __u8 target_address = USB_DIR_IN | usbatm->driver->isoc_in; in speedtch_bind()
839 for (i = 0; i < desc->desc.bNumEndpoints; i++) { in speedtch_bind()
840 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; in speedtch_bind()
842 if ((endpoint_desc->bEndpointAddress == target_address)) { in speedtch_bind()
850 usb_info(usbatm, "isochronous transfer not supported - using bulk\n"); in speedtch_bind()
853 if (!use_isoc && !instance->params.altsetting) in speedtch_bind()
859 if (!instance->params.altsetting) in speedtch_bind()
860 instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING; in speedtch_bind()
862 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); in speedtch_bind()
864 INIT_WORK(&instance->status_check_work, speedtch_check_status); in speedtch_bind()
865 timer_setup(&instance->status_check_timer, speedtch_status_poll, 0); in speedtch_bind()
866 instance->last_status = 0xff; in speedtch_bind()
867 instance->poll_delay = MIN_POLL_DELAY; in speedtch_bind()
869 timer_setup(&instance->resubmit_timer, speedtch_resubmit_int, 0); in speedtch_bind()
871 instance->int_urb = usb_alloc_urb(0, GFP_KERNEL); in speedtch_bind()
873 if (instance->int_urb) in speedtch_bind()
874 usb_fill_int_urb(instance->int_urb, usb_dev, in speedtch_bind()
876 instance->int_data, sizeof(instance->int_data), in speedtch_bind()
881 /* check whether the modem already seems to be alive */ in speedtch_bind()
884 instance->scratch_buffer + OFFSET_7, SIZE_7, 500); in speedtch_bind()
886 usbatm->flags |= (ret == SIZE_7 ? UDSL_SKIP_HEAVY_INIT : 0); in speedtch_bind()
888 …usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, usbatm->flags & UDSL_SKIP_HEAVY_INIT ? "alre… in speedtch_bind()
890 if (!(usbatm->flags & UDSL_SKIP_HEAVY_INIT)) in speedtch_bind()
896 usbatm->driver_data = instance; in speedtch_bind()
901 usb_free_urb(instance->int_urb); in speedtch_bind()
911 struct speedtch_instance_data *instance = usbatm->driver_data; in speedtch_unbind()
915 speedtch_release_interfaces(usb_dev, usb_dev->actconfig->desc.bNumInterfaces); in speedtch_unbind()
916 usb_free_urb(instance->int_urb); in speedtch_unbind()