Lines Matching +full:slew +full:- +full:time +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0-or-later
92 #define ST_SPUA 0x01 /* Strong Pull-up is active */
172 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), in ds_send_control_cmd()
175 dev_err(&dev->udev->dev, in ds_send_control_cmd()
188 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), in ds_send_control_mode()
191 dev_err(&dev->udev->dev, in ds_send_control_mode()
204 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), in ds_send_control()
207 dev_err(&dev->udev->dev, in ds_send_control()
218 struct device *dev = &ds_dev->udev->dev; in ds_dump_status()
222 ds_dev->ep[EP_STATUS], count, count, buf); in ds_dump_status()
226 dev_dbg(dev, "1-wire speed: 0x%02x", buf[1]); in ds_dump_status()
229 dev_dbg(dev, "pulldown slew rate control: 0x%02x", buf[4]); in ds_dump_status()
230 dev_dbg(dev, "write-1 low time: 0x%02x", buf[5]); in ds_dump_status()
231 dev_dbg(dev, "data sample offset/write-0 recovery time: 0x%02x", buf[6]); in ds_dump_status()
237 dev_dbg(dev, "1-wire data output buffer status: 0x%02x", buf[12]); in ds_dump_status()
238 dev_dbg(dev, "1-wire data input buffer status: 0x%02x", buf[13]); in ds_dump_status()
276 err = usb_interrupt_msg(dev->udev, in ds_recv_status()
277 usb_rcvintpipe(dev->udev, in ds_recv_status()
278 dev->ep[EP_STATUS]), in ds_recv_status()
279 dev->st_buf, sizeof(dev->st_buf), in ds_recv_status()
282 dev_err(&dev->udev->dev, in ds_recv_status()
283 "Failed to read 1-wire data from 0x%x: err=%d.\n", in ds_recv_status()
284 dev->ep[EP_STATUS], err); in ds_recv_status()
289 memcpy(st, dev->st_buf, sizeof(*st)); in ds_recv_status()
301 dev_err(&dev->udev->dev, in ds_reset_device()
303 /* Chip strong pullup time was cleared. */ in ds_reset_device()
304 if (dev->spu_sleep) { in ds_reset_device()
306 u8 del = dev->spu_sleep>>4; in ds_reset_device()
309 dev_err(&dev->udev->dev, in ds_reset_device()
328 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), in ds_recv_data()
333 dev_info(&dev->udev->dev, "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]); in ds_recv_data()
334 usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN])); in ds_recv_data()
336 /* status might tell us why endpoint is stuck? */ in ds_recv_data()
339 ds_dump_status(dev, dev->st_buf, recv_len); in ds_recv_data()
362 …err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, … in ds_send_data()
364 dev_err(&dev->udev->dev, "Failed to write 1-wire data to ep0x%x: " in ds_send_data()
365 "err=%d.\n", dev->ep[EP_DATA_OUT], err); in ds_send_data()
432 st->status = 0; in ds_wait_status()
437 printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], err); in ds_wait_status()
439 printk("%02x ", dev->st_buf[i]); in ds_wait_status()
443 } while (!(st->status & ST_IDLE) && !(err < 0) && ++count < 100); in ds_wait_status()
445 if (err >= 16 && st->status & ST_EPOF) { in ds_wait_status()
446 dev_info(&dev->udev->dev, "Resetting device after ST_EPOF.\n"); in ds_wait_status()
457 ds_dump_status(dev, dev->st_buf, err); in ds_wait_status()
464 return -1; in ds_wait_status()
495 return -EINVAL;
518 dev->spu_bit = delay ? COMM_SPU : 0; in ds_set_pullup()
519 /* If delay is zero, it has already been disabled, if the time is in ds_set_pullup()
524 if (delay == 0 || ms == dev->spu_sleep) in ds_set_pullup()
531 dev->spu_sleep = ms; in ds_set_pullup()
562 * produce one time slot, a down followed by an up with COMM_D
581 err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | dev->spu_bit, byte); in ds_write_byte()
585 if (dev->spu_bit) in ds_write_byte()
586 msleep(dev->spu_sleep); in ds_write_byte()
592 err = ds_recv_data(dev, &dev->byte_buf, 1); in ds_write_byte()
596 return !(byte == dev->byte_buf); in ds_write_byte()
623 return -E2BIG; in ds_read_block()
652 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | dev->spu_bit, len); in ds_write_block()
656 if (dev->spu_bit) in ds_write_block()
657 msleep(dev->spu_sleep); in ds_write_block()
676 * more, search_limit IDs will be returned followed by a non-zero in ds9490r_search()
688 * discovering 8 devices (1 bulk transfer and 1/2 FIFO size) at a time. in ds9490r_search()
705 found_ids = kmalloc_array(master->max_slave_count, sizeof(u64), GFP_KERNEL); in ds9490r_search()
711 mutex_lock(&master->bus_mutex); in ds9490r_search()
714 if (ds_send_data(dev, (u8 *)&master->search_id, 8) < 0) in ds9490r_search()
716 master->search_id = 0; in ds9490r_search()
720 search_limit = master->max_slave_count; in ds9490r_search()
753 master->search_id = buf[i]; in ds9490r_search()
759 if (test_bit(W1_ABORT_SEARCH, &master->flags)) in ds9490r_search()
765 master->search_id = 0; in ds9490r_search()
766 } else if (!test_bit(W1_WARN_MAX_COUNT, &master->flags)) { in ds9490r_search()
775 dev_info(&dev->udev->dev, "%s: max_slave_count %d reached, " in ds9490r_search()
777 master->max_slave_count); in ds9490r_search()
778 set_bit(W1_WARN_MAX_COUNT, &master->flags); in ds9490r_search()
782 mutex_unlock(&master->bus_mutex); in ds9490r_search()
845 if (ds_touch_bit(dev, bit, &dev->byte_buf)) in ds9490r_touch_bit()
848 return dev->byte_buf; in ds9490r_touch_bit()
864 err = ds_touch_bit(dev, 1, &dev->byte_buf);
868 return dev->byte_buf & 1;
884 err = ds_read_byte(dev, &dev->byte_buf); in ds9490r_read_byte()
888 return dev->byte_buf; in ds9490r_read_byte()
954 memset(&dev->master, 0, sizeof(struct w1_bus_master)); in ds_w1_init()
968 dev->master.data = dev; in ds_w1_init()
969 dev->master.touch_bit = &ds9490r_touch_bit; in ds_w1_init()
973 * individual time slot at the lowest level. The requirement from in ds_w1_init()
974 * pulling the bus state down to reading the state is 15us, something in ds_w1_init()
976 dev->master.read_bit = &ds9490r_read_bit; in ds_w1_init()
977 dev->master.write_bit = &ds9490r_write_bit; in ds_w1_init()
979 dev->master.read_byte = &ds9490r_read_byte; in ds_w1_init()
980 dev->master.write_byte = &ds9490r_write_byte; in ds_w1_init()
981 dev->master.read_block = &ds9490r_read_block; in ds_w1_init()
982 dev->master.write_block = &ds9490r_write_block; in ds_w1_init()
983 dev->master.reset_bus = &ds9490r_reset; in ds_w1_init()
984 dev->master.set_pullup = &ds9490r_set_pullup; in ds_w1_init()
985 dev->master.search = &ds9490r_search; in ds_w1_init()
987 return w1_add_master_device(&dev->master); in ds_w1_init()
992 w1_remove_master_device(&dev->master); in ds_w1_fini()
1006 return -ENOMEM; in ds_probe()
1008 dev->udev = usb_get_dev(udev); in ds_probe()
1009 if (!dev->udev) { in ds_probe()
1010 err = -ENOMEM; in ds_probe()
1013 memset(dev->ep, 0, sizeof(dev->ep)); in ds_probe()
1017 err = usb_reset_configuration(dev->udev); in ds_probe()
1019 dev_err(&dev->udev->dev, in ds_probe()
1026 err = usb_set_interface(dev->udev, in ds_probe()
1027 intf->cur_altsetting->desc.bInterfaceNumber, alt); in ds_probe()
1029 dev_err(&dev->udev->dev, "Failed to set alternative setting %d " in ds_probe()
1031 intf->cur_altsetting->desc.bInterfaceNumber, err); in ds_probe()
1035 iface_desc = intf->cur_altsetting; in ds_probe()
1036 if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { in ds_probe()
1037 dev_err(&dev->udev->dev, "Num endpoints=%d. It is not DS9490R.\n", in ds_probe()
1038 iface_desc->desc.bNumEndpoints); in ds_probe()
1039 err = -EINVAL; in ds_probe()
1045 * so we will fill only 1-3 endpoints entry. in ds_probe()
1047 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { in ds_probe()
1048 endpoint = &iface_desc->endpoint[i].desc; in ds_probe()
1050 dev->ep[i+1] = endpoint->bEndpointAddress; in ds_probe()
1053 i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), in ds_probe()
1054 (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", in ds_probe()
1055 endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); in ds_probe()
1064 list_add_tail(&dev->ds_entry, &ds_devices); in ds_probe()
1071 usb_put_dev(dev->udev); in ds_probe()
1086 list_del(&dev->ds_entry); in ds_disconnect()
1093 usb_put_dev(dev->udev); in ds_disconnect()
1112 MODULE_DESCRIPTION("DS2490 USB <-> W1 bus master driver (DS9490*)");