Lines Matching +full:slave +full:- +full:addr

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (C) 2008-2009 Semihalf, Michal Hajduk and Bartlomiej Sieka
60 uint32_t addr; member
75 fprintf(stderr, "usage: %s -a addr [-f device] [-d [r|w]] [-o offset] " in usage()
76 "[-w [0|8|16|16LE|16BE]] [-c count] [-m [tr|ss|rs|no]] [-b] [-v]\n", in usage()
78 fprintf(stderr, " %s -s [-f device] [-n skip_addr] -v\n", in usage()
80 fprintf(stderr, " %s -r [-f device] -v\n", getprogname()); in usage()
168 usage("Bad -n argument, expected (first) hex-digit"); in parse_skip()
171 usage("Bad -n argument, expected (second) hex-digit"); in parse_skip()
174 usage("Bad -n argument, (01..7f)"); in parse_skip()
181 if (*p == '-') { in parse_skip()
186 usage("Bad -n argument, ([:|,|..|-])"); in parse_skip()
191 usage("Bad -n argument, expected (first) hex-digit"); in parse_skip()
194 usage("Bad -n argument, expected (second) hex-digit"); in parse_skip()
197 usage("Bad -n argument, (01..7f)"); in parse_skip()
199 usage("Bad -n argument, (end < start)"); in parse_skip()
230 cmd.slave = u << 1; in scan_bus()
240 rdmsg.slave = u << 1; in scan_bus()
265 "trying less-reliable read method.\n"); in scan_bus()
294 return ("Invalid 8-bit offset\n"); in encode_offset()
300 return ("Invalid 16-bit offset\n"); in encode_offset()
319 cmd->count = i2c_opt.off_len; in write_offset()
320 cmd->buf = (void*)i2c_opt.off_buf; in write_offset()
333 cmd.slave = i2c_opt.addr; in i2c_write()
401 cmd.slave = i2c_opt.addr; in i2c_read()
416 cmd.slave = i2c_opt.addr | 1; in i2c_read()
438 * i2c_rdwr_transfer() - use I2CRDWR to conduct a complete i2c transfer.
440 * Some i2c hardware is unable to provide direct control over START, REPEAT-
442 * START-<data>-STOP or START-<data>-REPEAT-START-<data>-STOP sequence as a
456 msgp->flags = IIC_M_WR | IIC_M_NOSTOP; in i2c_rdwr_transfer()
457 msgp->slave = i2c_opt.addr; in i2c_rdwr_transfer()
458 msgp->buf = i2c_opt.off_buf; in i2c_rdwr_transfer()
459 msgp->len = i2c_opt.off_len; in i2c_rdwr_transfer()
468 * a start; if we did an offset write above it'll be a repeat-start in i2c_rdwr_transfer()
472 msgp->flags = IIC_M_WR | flag; in i2c_rdwr_transfer()
474 msgp->flags = IIC_M_RD; in i2c_rdwr_transfer()
475 msgp->slave = i2c_opt.addr; in i2c_rdwr_transfer()
476 msgp->len = i2c_opt.count; in i2c_rdwr_transfer()
477 msgp->buf = i2c_buf; in i2c_rdwr_transfer()
481 xfer.nmsgs = msgp - msgs; in i2c_rdwr_transfer()
483 if (ioctl(fd, I2CRDWR, &xfer) == -1 ) in i2c_rdwr_transfer()
524 if ((u % chunk_size) == chunk_size - 1) in access_bus()
582 return(-1); in command_bus()
589 return(-1); in command_bus()
592 i2c_opt.addr = strtoul(cmd, &cmd, 0); in command_bus()
593 if (i2c_opt.addr == 0 && errno == EINVAL) { in command_bus()
595 return(-1); in command_bus()
597 if (i2c_opt.addr < 1 || i2c_opt.addr > 0x7f) { in command_bus()
598 fprintf(stderr, "Invalid device (0x%x)\n", i2c_opt.addr); in command_bus()
599 return(-1); in command_bus()
601 i2c_opt.addr <<= 1; in command_bus()
618 return(-1); in command_bus()
624 return(-1); in command_bus()
631 return(-1); in command_bus()
638 return(-1); in command_bus()
649 return(-1); in command_bus()
657 return(-1); in command_bus()
661 return(-1); in command_bus()
671 if (fd == -1) { in command_bus()
681 return(-1); in command_bus()
719 while (argc-- > 0) { in instruct_bus()
720 if (argc == 0 && !strcmp(*argv, "-")) { in instruct_bus()
750 fd_cache[ch] = -1; in main()
754 i2c_opt.addr = 0; in main()
765 while ((ch = getopt(argc, argv, optflags)) != -1) { in main()
772 usage("Only one of [-a|-h|-r|-s]"); in main()
786 case 0: usage("Pick one of [-a|-h|-i|-r|-s]"); break; in main()
797 while ((ch = getopt(argc, argv, optflags)) != -1) { in main()
800 i2c_opt.addr = strtoul(optarg, 0, 16); in main()
801 if (i2c_opt.addr == 0 && errno == EINVAL) in main()
802 usage("Bad -a argument (hex)"); in main()
803 if (i2c_opt.addr == 0 || i2c_opt.addr > 0x7f) in main()
804 usage("Bad -a argument (01..7f)"); in main()
805 i2c_opt.addr <<= 1; in main()
813 usage("Bad -c argument (decimal)"); in main()
817 usage("Bad -d argument ([r|w])"); in main()
834 usage("Bad -m argument ([no|ss|rs|tr])"); in main()
842 usage("Bad -o argument (hex)"); in main()
853 fprintf(stderr, "Illegal -%c option", ch); in main()
857 argc -= optind; in main()
864 /* Set default mode if option -m is not specified */ in main()
880 if (fd == -1) { in main()
889 fprintf(stderr, "dev: %s, addr: 0x%x, r/w: %c, " in main()
891 i2c_opt.addr >> 1, i2c_opt.dir, i2c_opt.off, in main()