From owner-freebsd-arm@FreeBSD.ORG Sat Nov 8 04:09:07 2014 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CEC5C9BA; Sat, 8 Nov 2014 04:09:07 +0000 (UTC) Received: from st11p02mm-asmtp001.mac.com (st11p02mm-asmtp001.mac.com [17.172.220.236]) (using TLSv1 with cipher DES-CBC3-SHA (112/168 bits)) (Client CN "smtp.me.com", Issuer "VeriSign Class 3 Extended Validation SSL SGC CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A2F4D907; Sat, 8 Nov 2014 04:09:07 +0000 (UTC) Received: from fukuyama.hsd1.ca.comcast.net (unknown [73.162.13.215]) by st11p02mm-asmtp001.mac.com (Oracle Communications Messaging Server 7u4-27.10(7.0.4.27.9) 64bit (built Jun 6 2014)) with ESMTPSA id <0NEP00707CUH2S70@st11p02mm-asmtp001.mac.com>; Sat, 08 Nov 2014 04:08:43 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52,1.0.28,0.0.0000 definitions=2014-11-08_01:2014-11-07,2014-11-07,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1408290000 definitions=main-1411080043 Content-type: text/plain; charset=windows-1252 MIME-version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) Subject: Re: libgpio From: Rui Paulo In-reply-to: <58908C87-6046-4873-87B1-74995EFA72D1@bsdimp.com> Date: Fri, 07 Nov 2014 20:08:40 -0800 Content-transfer-encoding: quoted-printable Message-id: <7B37033A-A7DC-4328-90E0-F33A2A008D68@me.com> References: <58908C87-6046-4873-87B1-74995EFA72D1@bsdimp.com> To: Warner Losh X-Mailer: Apple Mail (2.1990.1) Cc: arm@freebsd.org, embedded@freebsd.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Nov 2014 04:09:07 -0000 On Nov 7, 2014, at 07:44, Warner Losh wrote: > I generally like it. Here=92s some suggestions, though many may be = hard given that our gpio interface is a bit weak. >=20 > First, there=92s no way to set multiple pins at the same time. That=92s = likely a reflection of our GPIO system, I know, but it is a deficiency. = Fortunately, most devices can tolerate multiple pins changing at = different times before a =91clock=92 or =91enable=92 pin forces them to = latch their state. OK; I'll work on an API that does this even if it's just a for loop = setting multiple pins to their state. > What the heck is g_caps? There=92s nothing at all to describe it. Not = even an indirection to look at sys/gpio.h It's what describes the pin: input/output/pullup/etc. I'll add some = documentation. I need to write a man page anyway. > For systems that have multiple GPIO devices (some have a few hundred = I/O lines that can be addressed), how > do you handle that? Do you just kinda have to know these details? Right now you have to work with each individually. We could change it = so that it opens all gpio devices and provides a structure that includes = all pins. > There=92s no facilities for interrupts (usually you=92d like to say = =93wait for this line to change and let me know=94). I know that the = Atmel gpio stuff did this, but I don=92t think that made it into the = generalization that was later done. There's no kernel support for it, but the library could create a thread = to poll the pin to see if it has changed. It's wasteful, but I don't = see any better way until we have GPIO interrupts. > I=92m not sure that I like the gpio_pin_* helper functions causing the = thing to change, rather than operating on a gpio_config_t. But since you = don=92t normally change a bunch at a time, that=92s not so bad. I just added those to make it easy to configure pins in one shot. > Finally a question: What does Linux do here? Is there a standard = interface that we could use to leverage off applications written for = Linux? Perhaps beyond the scope of what you=92re trying to do, but any = discussion about pushing things into the base should ask the question = =93Is this the right, most useful interface?=94 That was correctly answered by Johny. -- Rui Paulo