From owner-freebsd-arm@freebsd.org Sun Nov 10 15:16:12 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 E01D21B6DE0 for ; Sun, 10 Nov 2019 15:16:12 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2m.ore.mailhop.org (outbound2m.ore.mailhop.org [54.149.155.156]) (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 479yJX3gZTz446m for ; Sun, 10 Nov 2019 15:16:12 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1573398971; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=rK3yVkbxVL8rZS4j1hvazu6giuvN+Y1OXyZOG8FDE67KUsdRAQeFxMkEV/Di3dB3NwltuWkoiJ4pZ lVUjbUEy83j8FtBflonPpmPGr/TRmaAXE5nXvBgesqghnkc0ESO+AkMW6LGSmP9Gu9odtSwy9ANZgB gUP2nJ6qh1+wxEg/EuNVuMJ/57gXZNQAEXhN35nGcNgoIrnFY6/bd8bhHSJxdPsReo8TdjN8foaqsY hjD1SJkQa+19BsdTJAiXQ8JhFLYMSPb6NS3jn2Wg9kLKa+9pmpIbmcveZseMMu3uG53uexBY7Kh0nG S9BbXDgI+k4ZUK5lP/aFGx2Uqb2TpOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=tFAT3CSvbDlWvPZUvutxomebeOcvhVe7KV5kAxPYhWg=; b=HRiNygxs1teNil32C5xg/PndXBKCBX10/EpVYtp7VExfsiw7gdVTd66wcnoL6/0btJxzDka2ccdY/ 3yi7CW7ePmSRtOjdRIrIYs70p1E5YHnz2bqZniDeidXhLXO5ZO+1h5upggHH8R+NGykda8PZvVhYVT JcA3idwMiZu9DQWe6OiRr4WyamAPZFO+LqwyDrf46udd5xFOYh9CgMAoF4ZyQ0YLjCB9S45gKxyLvn l7tyFtTK/1US0826g0NkZtJZPDgo9O7TdHXd5Q4+lYJDiEEZX8NuNFOERPAdQ6WMl1Ob5vjFijDmef No4By02r31pAj3JVtOhvz2KSpzMiBSQ== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=tFAT3CSvbDlWvPZUvutxomebeOcvhVe7KV5kAxPYhWg=; b=g8HK0W/xwH+wbUtNBcMWoRtxJbsz5aPuKyps703kjQ0IMhHGQ5ya10bUgW4t3j/RxQ2+v9Yw2wJkf OA4IbcaF7z/OWRSThLlVB4xyPHmqf2Mqw5Fkh6hocrrrJb0On9sDi6iuLNLD4C2LEpmCoe/2IPA2fE DRxldUV9BIqI0jz7JyWwXRYgoXntUng+PWRoHj6cluz05JSSqaQeSXr37c4H3YDT05y/s/eJ076HnS ZD7SE6F+PM4nesFpUcMQiCuBKOi9Mat5hXUhbP9Y7Irac1cgd8kBA9wL416xeUdURZNCdk1FEN0306 WyorMbSfh5pUShnlEG3YcIb9vawu2RQ== X-MHO-RoutePath: aGlwcGll X-MHO-User: 02f62d47-03cd-11ea-829e-79a40d15cccd X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id 02f62d47-03cd-11ea-829e-79a40d15cccd; Sun, 10 Nov 2019 15:16:08 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id xAAFG3IA012040; Sun, 10 Nov 2019 08:16:03 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1dff42bdef54d3eca4791e5da729ee479b386731.camel@freebsd.org> Subject: Re: Can't write to IIC by I2CRDWR with two records 'struct iic_msg' From: Ian Lepore To: mishin@mh.san.ru, freebsd-arm@freebsd.org Date: Sun, 10 Nov 2019 08:16:03 -0700 In-Reply-To: <7ace6346d97d0bfe95cfab3cb6fa820b@mh.san.ru> References: <7ace6346d97d0bfe95cfab3cb6fa820b@mh.san.ru> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 479yJX3gZTz446m X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-2.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; ASN(0.00)[asn:16509, ipnet:54.148.0.0/15, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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 15:16:12 -0000 On Sun, 2019-11-10 at 16:55 +0400, mishin@mh.san.ru wrote: > 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} > }; Some i2c hardware controller drivers don't properly support the NOSTOP and NOSTART flags. Sometimes it's a bug, and sometimes it's because hardware limitations prevent it. In the allwinner case, I think it's a bug, but manu would know for sure. -- Ian > 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); > } > _______________________________________________ > freebsd-arm@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org > "