From owner-freebsd-arm@FreeBSD.ORG Fri Nov 7 15:44:47 2014 Return-Path: Delivered-To: arm@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 27B404A9 for ; Fri, 7 Nov 2014 15:44:47 +0000 (UTC) Received: from mail-ig0-f182.google.com (mail-ig0-f182.google.com [209.85.213.182]) (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 E3CD7788 for ; Fri, 7 Nov 2014 15:44:46 +0000 (UTC) Received: by mail-ig0-f182.google.com with SMTP id hn18so5597643igb.3 for ; Fri, 07 Nov 2014 07:44:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=khTZ/wQPe6JVGuwnEovKV2pg8VMtN14KCQId0C2EBq8=; b=GOdze8nmKhx0xLBkKXhLnGC2Tl72W9f3A5CN9//drV51Am8JVOi/AwhUmz5EZYVbSI z5EGfTsBC2Q21pP0ZukU4ZRwhgzeEZ/E1xyIWhGMClMJzYoEnaq8YtH+OeDea3zlVd1f YN5BrlrpLqrRBXD1WepKjI9ZzXNT29r/l9r0XHZ6OW23HRMdJtP0JzZABy8UEJaB4ykp 0t6wP6aPWGhQO4PRIbYK3VA7ntzH0KvJmHU9Sk1L76NZ+i7jDrWqlHNCsYmt+d9WzXg2 B3WxniSqLd7ZPrp31J08WqUmIXscoI7qHYMKsFysvLR9BDxwHfjxbwTGX/gaKRP39qnW zOGg== X-Gm-Message-State: ALoCoQm/XAmU0kKWZFi+FoeBL9SGQUM7Hn1L8V3g96wgO+NTaIpPgQmo5T9kd8t/cjjKCzMIjgZj X-Received: by 10.50.43.197 with SMTP id y5mr4680485igl.33.1415375073961; Fri, 07 Nov 2014 07:44:33 -0800 (PST) Received: from bsdimp.bsdimp.com ([50.253.99.174]) by mx.google.com with ESMTPSA id n29sm4407815ioe.19.2014.11.07.07.44.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 07:44:33 -0800 (PST) Sender: Warner Losh Content-Type: multipart/signed; boundary="Apple-Mail=_E873F49E-869E-44FD-8979-473D22DE02FD"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: libgpio From: Warner Losh In-Reply-To: Date: Fri, 7 Nov 2014 08:44:30 -0700 Message-Id: <58908C87-6046-4873-87B1-74995EFA72D1@bsdimp.com> References: To: Rui Paulo X-Mailer: Apple Mail (2.1878.6) 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: Fri, 07 Nov 2014 15:44:47 -0000 --Apple-Mail=_E873F49E-869E-44FD-8979-473D22DE02FD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 On Nov 6, 2014, at 11:41 PM, Rui Paulo wrote: > Hi, >=20 > Some time ago, I wrote a gpio library as a way to interact with the = kernel gpio driver in a more sensible way (hiding the details of opening = a /dev file, handling all the ioctls, etc.). >=20 > Here's the project code: >=20 > https://bitbucket.org/rpaulo/libgpio/src >=20 > Here's the header file: >=20 > = https://bitbucket.org/rpaulo/libgpio/src/1dfe793d0b0cd6caff2e196cf667a5c06= bbade8d/libgpio.h?at=3Ddefault >=20 > 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 gpioctl to use it and I'm open to changing the library API. >=20 > Any comments? I generally like it. Here=92s some suggestions, though many may be hard = given that our gpio interface is a bit weak. 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. What the heck is g_caps? There=92s nothing at all to describe it. Not = 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=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. 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. 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 Warner --Apple-Mail=_E873F49E-869E-44FD-8979-473D22DE02FD Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJUXOjeAAoJEGwc0Sh9sBEA1RoP/2piAIsGxJ32VaI2x3Bj5p2A hzg8VpRsYSdJmLfaHbcVoSWY0h/HAJiKqSIvEnFE+1D97s91nNU7VhiYSayvGc6R NRKfZqugAzPSZUDACx6dY6huYpva4JlVdDHnQgoG6Wxdlcy565NlJVXTLuu5yeB4 OzQzX7upJUNUckFIWReTJmWAwYuGMQqSHQmWBEW0Hrg/94zemaCBXpekb4rOyiOx cVjvxr204KWfCk5iUVmo/MIKPOwMSBschUx+oyQQLAaE2ROnPQzYwmHKBN16NaMG SuzaO9TNKerGJxRaMGc5KyRAcprJ4C2I6A0HQUCZEcE0/d59D14FGi3zAqHffXCp qmYN7hmWBoYlb2ctlKhDcWmB2QrZ4z6V0E0ZI2RAkeoR2bmFfNmmbeUUWR8IjeRq roKjJfJj+Zvk52Du9OoNLPXd+YM6MdZCYQumbRRufVdK/+zKUgseGZzqwa8l+ivt knXVDPUa71v1703iHz1oFknuc2fpnPogKZFH2KW/LfRAXDtMpFtqYxd0UcCJgyZR 0rFKiwjKyZPu0X9lnYLbL98DYmVhB6eKOdLXQIudLs+QCuc9FyEgPTU6o1jjb+lb Io/+DTwO9tKrO9WFrrIoQwA1qTp7Y+ukG8/4VivcQTPmJvhhGcQ+IlT/Xa6j16vh eQrsQLn3nuJC4VxxBgQg =7WX+ -----END PGP SIGNATURE----- --Apple-Mail=_E873F49E-869E-44FD-8979-473D22DE02FD--