From owner-freebsd-embedded@FreeBSD.ORG Sun Apr 12 01:00:59 2015 Return-Path: Delivered-To: embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 73C56F31; Sun, 12 Apr 2015 01:00:59 +0000 (UTC) Received: from st11p00mm-asmtp003.mac.com (st11p00mm-asmtp003.mac.com [17.172.81.2]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4A21DEE8; Sun, 12 Apr 2015 01:00:58 +0000 (UTC) Received: from akita.localnet (c-73-162-13-215.hsd1.ca.comcast.net [73.162.13.215]) by st11p00mm-asmtp003.mac.com (Oracle Communications Messaging Server 7.0.5.35.0 64bit (built Dec 4 2014)) with ESMTPSA id <0NMO00CQ05HEDJ00@st11p00mm-asmtp003.mac.com>; Sun, 12 Apr 2015 01:00:52 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68,1.0.33,0.0.0000 definitions=2015-04-12_01:2015-04-10,2015-04-11,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=4 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1412110000 definitions=main-1504120008 From: Rui Paulo To: freebsd-arch@freebsd.org Subject: Re: using libgpio to bitbang LCDs! Date: Sat, 11 Apr 2015 18:00:46 -0700 Message-id: <7527478.9HOi23WthO@akita> User-Agent: KMail/4.14.3 (FreeBSD/11.0-CURRENT; KDE/4.14.3; amd64; ; ) In-reply-to: References: MIME-version: 1.0 Content-transfer-encoding: 7Bit Content-type: text/plain; charset=us-ascii Cc: "freebsd-embedded@freebsd.org" X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2015 01:00:59 -0000 On Saturday 11 April 2015 17:11:47 Adrian Chadd wrote: > Hi! > > I just ported an adafruit LCD driver to FreeBSD. This was a pretty trivial > task: > > * convert C++ to C, which was done primarily to not rely on the > arduino-isms; * use libgpio to bitbang the SPI bus needed to write to the > LCD. > > It worked third time. First was "oh it runs on 5v power and 3.3v > signaling", and I had it hooked up to 3.3. Second was "Oh, I haven't > set the pins to be output pins yet." Third time worked - just slowly. > > However - using libgpio was just pleasant. Get a handle, set the pin > config, set the pins high/low. It was pretty damned wonderful. > > It turns out that to fill the screen with individual pixel writes > takes quite a few seconds pinning my AR9331 CPU doing ~ 190,000 > syscalls a second. Ian's suggested something sensible - a bulk data > ioctl() that can bit bang a series of GPIO pins in the kernel. Ie, one > syscall, a big chunk of data with instructions and timings. Since this is an LCD, you probably want a way to export the GPIO bank via mmap with write-combining enabled. It's not really a safe operation as it could hang the GPIO driver, but it could be useful. > The other interesting thing would be a kind of bulk pin set/get - ie, > instead of doing rmw for one pin at a time, communicate down masks of > pins to do together. I think that's sensible and could be done via a separate (new) ioctl. -- Rui Paulo