From owner-freebsd-arm@freebsd.org Wed Apr 24 11:00:47 2019 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F13415950FA for ; Wed, 24 Apr 2019 11:00:47 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id EE0168782A for ; Wed, 24 Apr 2019 11:00:46 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id 8b786ff8; Wed, 24 Apr 2019 13:00:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mail; bh=U8ICVmGt+ABKEaI2+p7PQtcWr5E=; b=sSMDvWbIQmhRhfEWGZ1HIfWaLt7L bcWFBtlDL2H6HNKnNiZYVYtQIlQDjOCY/x0s40JXzU6dd+DMh8sAdBmUw+HEMfGZ lZz5iKikACdt75Uku4MY5oKxgSTBHe7xbk1xmV02lUra++3Dvge5DuHqbO5pYKFK wWaYaAyRkstB5FY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= mail; b=CxXjjURnK1zHoPB2yhs/NGC9xoCHaZpyJrHm1uK2KqHEPwEoIoCZCjjL EPeC0MUXK3T7IQqFdOg/YwLsGVPgjSbm1U8CDyVtY1FODkbVw+soB0yAodWTFUVk /Cq/6eKDMLZL3M0jWxVPt+8u2AyRayHB4r0n3hoSpaotfCU60Q0= Received: from skull.home.blih.net (ip-9.net-89-3-105.rev.numericable.fr [89.3.105.9]) by mail.blih.net (OpenSMTPD) with ESMTPSA id 16bc6db4 TLS version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Wed, 24 Apr 2019 13:00:39 +0200 (CEST) Date: Wed, 24 Apr 2019 13:00:39 +0200 From: Emmanuel Vadot To: Manuel =?ISO-8859-1?Q?St=FChn?= Cc: freebsd-arm@freebsd.org Subject: Re: I2C on Allwinner NanoPI Neo2 Message-Id: <20190424130039.2b425b0f3a2dda9affa41952@bidouilliste.com> In-Reply-To: <20190424122134.36e8dc112c62486d00703d4f@freenet.de> References: <20190424122134.36e8dc112c62486d00703d4f@freenet.de> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd13.0) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: EE0168782A X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-7.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] 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: Wed, 24 Apr 2019 11:00:47 -0000 Hi Manuel, On Wed, 24 Apr 2019 12:21:34 +0200 Manuel St=FChn wrote: > Hi, >=20 > On my Allwinner NanoPI NEO2 (H5 aarch64 based) the I2C("allwinner,sun6i-a= 31-i2c" compatible, debug messages enabled) shows this message: >=20 > root@bsd-nanopi:~ # i2c -v -f /dev/iic0 -a0x3c -d r -c 1 > dev: /dev/iic0, addr: 0x3c, r/w:twsi_locked_start(): no ACK (status: 08) = after sending slave address r, offset: 0x00, width: 8, count: 1 > ioctl: error sending start condition >=20 > while trying to communicate with the attached NanoHAT OLED (SSD1306 based= I2C 0.96inch 128x64 display). >=20 > Observing the bus with a logic analyzer shows, that between start conditi= on and the address write there is a 10ms pause. Then the address gets writt= en correctly and=20 > the device answers ACK. The I2C-clock is 100kHz which is confirmed by log= ic analyzer. >=20 > I'm assuming that this long delay between start condition and address wri= te causes this error, but i do not find any problem in the i2c driver(iicbu= s/twsi*). I've crosschecked the board with the default Linux image, and I2C= works there without problems and there is no visible delay between start a= nd addr-wr. >=20 > Any ideas? >=20 > --=20 > Manuel i2c(8) uses the start/stop/read/write ioctls on the i2c device and those don't use interrupts but a lots of DELAY calls. I've spent a few hours trying to make things work without interrupts but gave up and added i2c_transfer support to twsi that supports interrupts. I guess that adding I2CRDWR (the ioctls that will call i2c_transfer) to i2c(8) will not be that hard. So either do that or just code a little program that suits your needs (see https://lists.freebsd.org/pipermail/freebsd-arm/2019-April/019672.html for more info on this). Cheers, --=20 Emmanuel Vadot