From owner-freebsd-arm@freebsd.org Sun Nov 10 12:55:26 2019 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CB961B3D2D for ; Sun, 10 Nov 2019 12:55:26 +0000 (UTC) (envelope-from mishin@mh.san.ru) Received: from frog.mh.net.ru (mh.balakovo.san.ru [88.147.158.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 479vB346dfz3xX0 for ; Sun, 10 Nov 2019 12:55:22 +0000 (UTC) (envelope-from mishin@mh.san.ru) Received: from mail.mh.net.ru (mouse.home [192.168.5.6]) by frog.mh.net.ru (Postfix) with ESMTPSA id 65557DA567 for ; Sun, 10 Nov 2019 16:55:13 +0400 (+04) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 10 Nov 2019 16:55:13 +0400 From: mishin@mh.san.ru To: freebsd-arm@freebsd.org Subject: Can't write to IIC by I2CRDWR with two records 'struct iic_msg' Message-ID: <7ace6346d97d0bfe95cfab3cb6fa820b@mh.san.ru> X-Sender: mishin@mh.san.ru User-Agent: Roundcube Webmail/1.3.9 X-Rspamd-Queue-Id: 479vB346dfz3xX0 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mishin@mh.san.ru designates 88.147.158.22 as permitted sender) smtp.mailfrom=mishin@mh.san.ru X-Spamd-Result: default: False [-0.89 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-0.77)[-0.769,0]; IP_SCORE(1.04)[ipnet: 88.147.128.0/17(2.84), asn: 12389(2.33), country: RU(0.01)]; R_SPF_ALLOW(-0.20)[+mx]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arm@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-0.86)[-0.863,0]; DMARC_NA(0.00)[san.ru]; FROM_NO_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:12389, ipnet:88.147.128.0/17, country:RU]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 12:55:26 -0000 About a system: 1. FreeBSD betta 12.1-STABLE FreeBSD 12.1-STABLE r354236 OPI_ZERO arm 2. Allwinner H2+ 3. iichb0: mem 0x1c2ac00-0x1c2afff irq 35 on simplebus0 iicbus0: on iichb0 iic0: on iicbus0 I trying to send a data array following a register value to a SSD1306 display from 'Allwinner H2+' by a following method (according to `i2c.c`): char SSD1306::iic_write(uint8_t offset, uint8_t data[], uint16_t size) const { struct iic_msg msgs[2] = { {slave_addr, IIC_M_WR | IIC_M_NOSTOP, sizeof(offset), &offset}, {slave_addr, IIC_M_WR | IIC_M_NOSTART, size, data} }; struct iic_rdwr_data xfer = {msgs, 2}; if ( ioctl(iic_handle, I2CRDWR, &xfer) == -1 ) { perror("ioctl(I2CRDWR)"); return(-1); }; return(0); }; iic_write(0x40, buffer, buffer_size); But something goes wrong and the display stills blank (no errors, though). But when I use an 'one record' struct with combined 'register+data' array (see below) or read by that 'two records' scheme (see below), all is ok. Have I made a mistake is flags or it is a feature or a bug? Thanks --- Next two methods works ok Read following write: char TEA5767::iic_read(uint8_t offset, uint8_t *data, uint16_t size) const { struct iic_msg msgs[2] = { {slave_addr, IIC_M_WR | IIC_M_NOSTOP, sizeof(offset), &offset}, {slave_addr, IIC_M_RD, size, data} }; struct iic_rdwr_data xfer = {msgs, 2}; if ( ioctl(iic_handle, I2CRDWR, &xfer) == -1) { perror("ioctl(I2CRDWR)"); return(-1); }; return(0); }; and write a combined 'register+data' array works too: char SSD1306::iic_write(uint8_t data[], uint16_t size) const { struct iic_msg msgs[1] = { {slave_addr, IIC_M_WR, size, data} }; struct iic_rdwr_data xfer = {msgs, 1}; if ( ioctl(iic_handle, I2CRDWR, &xfer) == -1) { perror("ioctl(I2CRDWR)"); return(-1); }; return(0); }