From owner-freebsd-embedded@FreeBSD.ORG Fri Nov 7 16:33:35 2014 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 75A6EC3D; Fri, 7 Nov 2014 16:33:35 +0000 (UTC) Received: from mail-wi0-x22d.google.com (mail-wi0-x22d.google.com [IPv6:2a00:1450:400c:c05::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1AC56CDF; Fri, 7 Nov 2014 16:33:35 +0000 (UTC) Received: by mail-wi0-f173.google.com with SMTP id n3so5129803wiv.0 for ; Fri, 07 Nov 2014 08:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=nPebHxOI+7J+V/qHpCi0rWTmwQk+G36U05NHYj5gXRE=; b=G32om1ZoPYROi0v/LgF78S/xseOc8cTEiHwZmDxg7kENh5+LFH+4IDcPvklaWG4pin HuORDuq9HBkBmzq3KPkADu7LCR4jKHOs9bo7qaIJ1Svxq1r8B0ROfKzI4hcUO1A0DO7H LK+TdOKpXFLvnf4Zw6bo7eGWiJT2iayFgad4DeMdIWczD5oepbGoL4pWod7E8YB9OcTS 71UK01opBWy9t3Eflh05rb3PZ++5sBP+x0j7xuodSvTQSgPk3QlPGmLI9+aYoGgkUKWt yT7y+WdUvvhbVYaABcq86VSwq4cBz6J8E/JLQuILcK7RtI9Dkp1utNAxAV1U1HGR3IlA e+YQ== MIME-Version: 1.0 X-Received: by 10.180.188.41 with SMTP id fx9mr6445118wic.59.1415378013470; Fri, 07 Nov 2014 08:33:33 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Fri, 7 Nov 2014 08:33:33 -0800 (PST) In-Reply-To: <58908C87-6046-4873-87B1-74995EFA72D1@bsdimp.com> References: <58908C87-6046-4873-87B1-74995EFA72D1@bsdimp.com> Date: Fri, 7 Nov 2014 08:33:33 -0800 X-Google-Sender-Auth: fyRA3o2ytBd428oP2CtZj4ml5PE Message-ID: Subject: Re: libgpio From: Adrian Chadd To: Warner Losh Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-arm@freebsd.org" , "freebsd-embedded@freebsd.org" , Rui Paulo 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: Fri, 07 Nov 2014 16:33:35 -0000 Hi, Yes, it'd be nice to (later) add an API call that takes multiple pin updates (and reads multiple pin updates.) That way higher speed, time critical stuff can be done for drivers that grow this feature and can do batched/timestamped GPIO events. -adrian On 7 November 2014 07:44, Warner Losh wrote: > > On Nov 6, 2014, at 11:41 PM, Rui Paulo wrote: > >> Hi, >> >> Some time ago, I wrote a gpio library as a way to interact with the kern= el gpio driver in a more sensible way (hiding the details of opening a /dev= file, handling all the ioctls, etc.). >> >> Here's the project code: >> >> https://bitbucket.org/rpaulo/libgpio/src >> >> Here's the header file: >> >> https://bitbucket.org/rpaulo/libgpio/src/1dfe793d0b0cd6caff2e196cf= 667a5c06bbade8d/libgpio.h?at=3Ddefault >> >> It looks like some people started using the library and I was wondering = if it would be a good candidate for the base system. I would rewrite gpioc= tl to use it and I'm open to changing the library API. >> >> Any comments? > > I generally like it. Here=E2=80=99s some suggestions, though many may be = hard given that our gpio interface is a bit weak. > > First, there=E2=80=99s no way to set multiple pins at the same time. That= =E2=80=99s likely a reflection of our GPIO system, I know, but it is a defi= ciency. Fortunately, most devices can tolerate multiple pins changing at di= fferent times before a =E2=80=98clock=E2=80=99 or =E2=80=98enable=E2=80=99 = pin forces them to latch their state. > > What the heck is g_caps? There=E2=80=99s nothing at all to describe it. N= ot even an indirection to look at sys/gpio.h > > 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? > > There=E2=80=99s no facilities for interrupts (usually you=E2=80=99d like = to say =E2=80=9Cwait for this line to change and let me know=E2=80=9D). I k= now that the Atmel gpio stuff did this, but I don=E2=80=99t think that made= it into the generalization that was later done. > > I=E2=80=99m 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 yo= u don=E2=80=99t normally change a bunch at a time, that=E2=80=99s not so ba= d. > > Finally a question: What does Linux do here? Is there a standard interfac= e that we could use to leverage off applications written for Linux? Perhaps= beyond the scope of what you=E2=80=99re trying to do, but any discussion a= bout pushing things into the base should ask the question =E2=80=9CIs this = the right, most useful interface?=E2=80=9D > > Warner