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()
308 dev_err(&dev->udev->dev, in ds_reset_device()
327 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), in ds_recv_data()
332 dev_info(&dev->udev->dev, "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]); in ds_recv_data()
333 usb_clear_halt(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN])); in ds_recv_data()
335 /* status might tell us why endpoint is stuck? */ in ds_recv_data()
338 ds_dump_status(dev, dev->st_buf, recv_len); in ds_recv_data()
361 …err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, … in ds_send_data()
363 dev_err(&dev->udev->dev, "Failed to write 1-wire data to ep0x%x: " in ds_send_data()
364 "err=%d.\n", dev->ep[EP_DATA_OUT], err); in ds_send_data()
431 st->status = 0; in ds_wait_status()
436 printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], err); in ds_wait_status()
438 printk("%02x ", dev->st_buf[i]); in ds_wait_status()
442 } while (!(st->status & ST_IDLE) && !(err < 0) && ++count < 100); in ds_wait_status()
444 if (err >= 16 && st->status & ST_EPOF) { in ds_wait_status()
445 dev_info(&dev->udev->dev, "Resetting device after ST_EPOF.\n"); in ds_wait_status()
456 ds_dump_status(dev, dev->st_buf, err); in ds_wait_status()
463 return -1; in ds_wait_status()
494 return -EINVAL;
517 dev->spu_bit = delay ? COMM_SPU : 0; in ds_set_pullup()
518 /* If delay is zero, it has already been disabled, if the time is in ds_set_pullup()
523 if (delay == 0 || ms == dev->spu_sleep) in ds_set_pullup()
530 dev->spu_sleep = ms; in ds_set_pullup()
561 * produce one time slot, a down followed by an up with COMM_D
580 err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | dev->spu_bit, byte); in ds_write_byte()
584 if (dev->spu_bit) in ds_write_byte()
585 msleep(dev->spu_sleep); in ds_write_byte()
591 err = ds_recv_data(dev, &dev->byte_buf, 1); in ds_write_byte()
595 return !(byte == dev->byte_buf); in ds_write_byte()
622 return -E2BIG; in ds_read_block()
651 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | dev->spu_bit, len); in ds_write_block()
655 if (dev->spu_bit) in ds_write_block()
656 msleep(dev->spu_sleep); in ds_write_block()
675 * more, search_limit IDs will be returned followed by a non-zero in ds9490r_search()
687 * discovering 8 devices (1 bulk transfer and 1/2 FIFO size) at a time. in ds9490r_search()
704 found_ids = kmalloc_array(master->max_slave_count, sizeof(u64), GFP_KERNEL); in ds9490r_search()
710 mutex_lock(&master->bus_mutex); in ds9490r_search()
713 if (ds_send_data(dev, (u8 *)&master->search_id, 8) < 0) in ds9490r_search()
715 master->search_id = 0; in ds9490r_search()
719 search_limit = master->max_slave_count; in ds9490r_search()
749 master->search_id = buf[i]; in ds9490r_search()
755 if (test_bit(W1_ABORT_SEARCH, &master->flags)) in ds9490r_search()
761 master->search_id = 0; in ds9490r_search()
762 } else if (!test_bit(W1_WARN_MAX_COUNT, &master->flags)) { in ds9490r_search()
770 dev_info(&dev->udev->dev, "%s: max_slave_count %d reached, " in ds9490r_search()
772 master->max_slave_count); in ds9490r_search()
773 set_bit(W1_WARN_MAX_COUNT, &master->flags); in ds9490r_search()
777 mutex_unlock(&master->bus_mutex); in ds9490r_search()
840 if (ds_touch_bit(dev, bit, &dev->byte_buf)) in ds9490r_touch_bit()
843 return dev->byte_buf; in ds9490r_touch_bit()
859 err = ds_touch_bit(dev, 1, &dev->byte_buf);
863 return dev->byte_buf & 1;
879 err = ds_read_byte(dev, &dev->byte_buf); in ds9490r_read_byte()
883 return dev->byte_buf; in ds9490r_read_byte()
949 memset(&dev->master, 0, sizeof(struct w1_bus_master)); in ds_w1_init()
963 dev->master.data = dev; in ds_w1_init()
964 dev->master.touch_bit = &ds9490r_touch_bit; in ds_w1_init()
968 * individual time slot at the lowest level. The requirement from in ds_w1_init()
969 * pulling the bus state down to reading the state is 15us, something in ds_w1_init()
971 dev->master.read_bit = &ds9490r_read_bit; in ds_w1_init()
972 dev->master.write_bit = &ds9490r_write_bit; in ds_w1_init()
974 dev->master.read_byte = &ds9490r_read_byte; in ds_w1_init()
975 dev->master.write_byte = &ds9490r_write_byte; in ds_w1_init()
976 dev->master.read_block = &ds9490r_read_block; in ds_w1_init()
977 dev->master.write_block = &ds9490r_write_block; in ds_w1_init()
978 dev->master.reset_bus = &ds9490r_reset; in ds_w1_init()
979 dev->master.set_pullup = &ds9490r_set_pullup; in ds_w1_init()
980 dev->master.search = &ds9490r_search; in ds_w1_init()
982 return w1_add_master_device(&dev->master); in ds_w1_init()
987 w1_remove_master_device(&dev->master); in ds_w1_fini()
1001 return -ENOMEM; in ds_probe()
1003 dev->udev = usb_get_dev(udev); in ds_probe()
1004 if (!dev->udev) { in ds_probe()
1005 err = -ENOMEM; in ds_probe()
1008 memset(dev->ep, 0, sizeof(dev->ep)); in ds_probe()
1012 err = usb_reset_configuration(dev->udev); in ds_probe()
1014 dev_err(&dev->udev->dev, in ds_probe()
1021 err = usb_set_interface(dev->udev, in ds_probe()
1022 intf->cur_altsetting->desc.bInterfaceNumber, alt); in ds_probe()
1024 dev_err(&dev->udev->dev, "Failed to set alternative setting %d " in ds_probe()
1026 intf->cur_altsetting->desc.bInterfaceNumber, err); in ds_probe()
1030 iface_desc = intf->cur_altsetting; in ds_probe()
1031 if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { in ds_probe()
1032 dev_err(&dev->udev->dev, "Num endpoints=%d. It is not DS9490R.\n", in ds_probe()
1033 iface_desc->desc.bNumEndpoints); in ds_probe()
1034 err = -EINVAL; in ds_probe()
1040 * so we will fill only 1-3 endpoints entry. in ds_probe()
1042 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { in ds_probe()
1043 endpoint = &iface_desc->endpoint[i].desc; in ds_probe()
1045 dev->ep[i+1] = endpoint->bEndpointAddress; in ds_probe()
1048 i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), in ds_probe()
1049 (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", in ds_probe()
1050 endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); in ds_probe()
1059 list_add_tail(&dev->ds_entry, &ds_devices); in ds_probe()
1066 usb_put_dev(dev->udev); in ds_probe()
1081 list_del(&dev->ds_entry); in ds_disconnect()
1088 usb_put_dev(dev->udev); in ds_disconnect()
1107 MODULE_DESCRIPTION("DS2490 USB <-> W1 bus master driver (DS9490*)");