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 */
101 /* 1-wire data i/o fifo size, 128 bytes */
174 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), in ds_send_control_cmd()
177 dev_err(&dev->udev->dev, in ds_send_control_cmd()
190 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), in ds_send_control_mode()
193 dev_err(&dev->udev->dev, in ds_send_control_mode()
206 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), in ds_send_control()
209 dev_err(&dev->udev->dev, in ds_send_control()
220 struct device *dev = &ds_dev->udev->dev; in ds_dump_status()
224 ds_dev->ep[EP_STATUS], count, count, buf); in ds_dump_status()
228 dev_dbg(dev, "1-wire speed: 0x%02x", buf[1]); in ds_dump_status()
231 dev_dbg(dev, "pulldown slew rate control: 0x%02x", buf[4]); in ds_dump_status()
232 dev_dbg(dev, "write-1 low time: 0x%02x", buf[5]); in ds_dump_status()
233 dev_dbg(dev, "data sample offset/write-0 recovery time: 0x%02x", buf[6]); in ds_dump_status()
239 dev_dbg(dev, "1-wire data output buffer status: 0x%02x", buf[12]); in ds_dump_status()
240 dev_dbg(dev, "1-wire data input buffer status: 0x%02x", buf[13]); in ds_dump_status()
278 err = usb_interrupt_msg(dev->udev, in ds_recv_status()
279 usb_rcvintpipe(dev->udev, in ds_recv_status()
280 dev->ep[EP_STATUS]), in ds_recv_status()
281 dev->st_buf, sizeof(dev->st_buf), in ds_recv_status()
284 dev_err(&dev->udev->dev, in ds_recv_status()
285 "Failed to read 1-wire data from 0x%x: err=%d.\n", in ds_recv_status()
286 dev->ep[EP_STATUS], err); in ds_recv_status()
291 memcpy(st, dev->st_buf, sizeof(*st)); in ds_recv_status()
303 dev_err(&dev->udev->dev, in ds_reset_device()
305 /* Chip strong pullup time was cleared. */ in ds_reset_device()
306 if (dev->spu_sleep) { in ds_reset_device()
308 u8 del = dev->spu_sleep>>4; in ds_reset_device()
311 dev_err(&dev->udev->dev, in ds_reset_device()
330 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), in ds_recv_data()
335 dev_info(&dev->udev->dev, "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]); in ds_recv_data()
336 usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN])); in ds_recv_data()
338 /* status might tell us why endpoint is stuck? */ in ds_recv_data()
341 ds_dump_status(dev, dev->st_buf, recv_len); in ds_recv_data()
364 …err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, … in ds_send_data()
366 dev_err(&dev->udev->dev, "Failed to write 1-wire data to ep0x%x: " in ds_send_data()
367 "err=%d.\n", dev->ep[EP_DATA_OUT], err); in ds_send_data()
434 st->status = 0; in ds_wait_status()
439 printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], err); in ds_wait_status()
441 printk("%02x ", dev->st_buf[i]); in ds_wait_status()
445 } while (!(st->status & ST_IDLE) && !(err < 0) && ++count < 100); in ds_wait_status()
447 if (err >= 16 && st->status & ST_EPOF) { in ds_wait_status()
448 dev_info(&dev->udev->dev, "Resetting device after ST_EPOF.\n"); in ds_wait_status()
459 ds_dump_status(dev, dev->st_buf, err); in ds_wait_status()
466 return -1; in ds_wait_status()
497 return -EINVAL;
520 dev->spu_bit = delay ? COMM_SPU : 0; in ds_set_pullup()
521 /* If delay is zero, it has already been disabled, if the time is in ds_set_pullup()
526 if (delay == 0 || ms == dev->spu_sleep) in ds_set_pullup()
533 dev->spu_sleep = ms; in ds_set_pullup()
564 * produce one time slot, a down followed by an up with COMM_D
583 err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | dev->spu_bit, byte); in ds_write_byte()
587 if (dev->spu_bit) in ds_write_byte()
588 msleep(dev->spu_sleep); in ds_write_byte()
594 err = ds_recv_data(dev, &dev->byte_buf, 1); in ds_write_byte()
598 return !(byte == dev->byte_buf); in ds_write_byte()
647 return -E2BIG; in ds_read_block()
651 err = read_block_chunk(dev, &buf[len - rem], to_read); in ds_read_block()
654 rem -= to_read; in ds_read_block()
669 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | dev->spu_bit, len); in ds_write_block()
673 if (dev->spu_bit) in ds_write_block()
674 msleep(dev->spu_sleep); in ds_write_block()
693 * more, search_limit IDs will be returned followed by a non-zero in ds9490r_search()
705 * discovering 8 devices (1 bulk transfer and 1/2 FIFO size) at a time. in ds9490r_search()
722 found_ids = kmalloc_array(master->max_slave_count, sizeof(u64), GFP_KERNEL); in ds9490r_search()
728 mutex_lock(&master->bus_mutex); in ds9490r_search()
731 if (ds_send_data(dev, (u8 *)&master->search_id, 8) < 0) in ds9490r_search()
733 master->search_id = 0; in ds9490r_search()
737 search_limit = master->max_slave_count; in ds9490r_search()
770 master->search_id = buf[i]; in ds9490r_search()
776 if (test_bit(W1_ABORT_SEARCH, &master->flags)) in ds9490r_search()
782 master->search_id = 0; in ds9490r_search()
783 } else if (!test_bit(W1_WARN_MAX_COUNT, &master->flags)) { in ds9490r_search()
792 dev_info(&dev->udev->dev, "%s: max_slave_count %d reached, " in ds9490r_search()
794 master->max_slave_count); in ds9490r_search()
795 set_bit(W1_WARN_MAX_COUNT, &master->flags); in ds9490r_search()
799 mutex_unlock(&master->bus_mutex); in ds9490r_search()
862 if (ds_touch_bit(dev, bit, &dev->byte_buf)) in ds9490r_touch_bit()
865 return dev->byte_buf; in ds9490r_touch_bit()
881 err = ds_touch_bit(dev, 1, &dev->byte_buf);
885 return dev->byte_buf & 1;
901 err = ds_read_byte(dev, &dev->byte_buf); in ds9490r_read_byte()
905 return dev->byte_buf; in ds9490r_read_byte()
971 memset(&dev->master, 0, sizeof(struct w1_bus_master)); in ds_w1_init()
985 dev->master.data = dev; in ds_w1_init()
986 dev->master.touch_bit = &ds9490r_touch_bit; in ds_w1_init()
990 * individual time slot at the lowest level. The requirement from in ds_w1_init()
991 * pulling the bus state down to reading the state is 15us, something in ds_w1_init()
993 dev->master.read_bit = &ds9490r_read_bit; in ds_w1_init()
994 dev->master.write_bit = &ds9490r_write_bit; in ds_w1_init()
996 dev->master.read_byte = &ds9490r_read_byte; in ds_w1_init()
997 dev->master.write_byte = &ds9490r_write_byte; in ds_w1_init()
998 dev->master.read_block = &ds9490r_read_block; in ds_w1_init()
999 dev->master.write_block = &ds9490r_write_block; in ds_w1_init()
1000 dev->master.reset_bus = &ds9490r_reset; in ds_w1_init()
1001 dev->master.set_pullup = &ds9490r_set_pullup; in ds_w1_init()
1002 dev->master.search = &ds9490r_search; in ds_w1_init()
1004 return w1_add_master_device(&dev->master); in ds_w1_init()
1009 w1_remove_master_device(&dev->master); in ds_w1_fini()
1023 return -ENOMEM; in ds_probe()
1025 dev->udev = usb_get_dev(udev); in ds_probe()
1026 if (!dev->udev) { in ds_probe()
1027 err = -ENOMEM; in ds_probe()
1030 memset(dev->ep, 0, sizeof(dev->ep)); in ds_probe()
1034 err = usb_reset_configuration(dev->udev); in ds_probe()
1036 dev_err(&dev->udev->dev, in ds_probe()
1043 err = usb_set_interface(dev->udev, in ds_probe()
1044 intf->cur_altsetting->desc.bInterfaceNumber, alt); in ds_probe()
1046 dev_err(&dev->udev->dev, "Failed to set alternative setting %d " in ds_probe()
1048 intf->cur_altsetting->desc.bInterfaceNumber, err); in ds_probe()
1052 iface_desc = intf->cur_altsetting; in ds_probe()
1053 if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { in ds_probe()
1054 dev_err(&dev->udev->dev, "Num endpoints=%d. It is not DS9490R.\n", in ds_probe()
1055 iface_desc->desc.bNumEndpoints); in ds_probe()
1056 err = -EINVAL; in ds_probe()
1062 * so we will fill only 1-3 endpoints entry. in ds_probe()
1064 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { in ds_probe()
1065 endpoint = &iface_desc->endpoint[i].desc; in ds_probe()
1067 dev->ep[i+1] = endpoint->bEndpointAddress; in ds_probe()
1070 i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), in ds_probe()
1071 (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", in ds_probe()
1072 endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); in ds_probe()
1081 list_add_tail(&dev->ds_entry, &ds_devices); in ds_probe()
1088 usb_put_dev(dev->udev); in ds_probe()
1103 list_del(&dev->ds_entry); in ds_disconnect()
1110 usb_put_dev(dev->udev); in ds_disconnect()
1129 MODULE_DESCRIPTION("DS2490 USB <-> W1 bus master driver (DS9490*)");