From owner-freebsd-arm@FreeBSD.ORG Mon Mar 2 19:31:03 2015 Return-Path: Delivered-To: freebsd-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 CD9484C0 for ; Mon, 2 Mar 2015 19:31:03 +0000 (UTC) Received: from mailhost.netlabit.sk (mailhost.netlabit.sk [84.245.65.72]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60B2A9DA for ; Mon, 2 Mar 2015 19:31:02 +0000 (UTC) Received: from zeta.dino.sk (fw1.dino.sk [84.245.95.252]) (AUTH: LOGIN milan) by mailhost.netlabit.sk with ESMTPA; Mon, 02 Mar 2015 20:30:58 +0100 id 00DCA89B.54F4BA72.000059A3 Date: Mon, 2 Mar 2015 20:30:58 +0100 From: Milan Obuch To: Luiz Otavio O Souza Subject: Re: Raspberry Pi with PiTFT - some GPIO weirdness Message-ID: <20150302203058.0d44266b@zeta.dino.sk> In-Reply-To: References: <20150228111852.15affe31@zeta.dino.sk> <20150228193658.6c872779@B85M-HD3-0.alogt.com> <20150228142424.6fed0ecf@zeta.dino.sk> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; i386-portbld-freebsd10.1) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-arm@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: Mon, 02 Mar 2015 19:31:03 -0000 On Sat, 28 Feb 2015 15:43:30 -0300 Luiz Otavio O Souza wrote: > On 28 February 2015 at 10:24, Milan Obuch wrote: > > On Sat, 28 Feb 2015 19:36:58 +0800 > > Erich Dollansky wrote: > > > >> Hi, > >> > >> On Sat, 28 Feb 2015 11:18:52 +0100 > >> Milan Obuch wrote: > >> > >> > today I found some time to play a bit with my little display > >> > attached to Rasoberry Pi, and I decided to test buttons connected > >> > to GPIO, as this should work on FreeBSD already. According docs, > >> > buttons are connected to GPIO lines 23, 22, 21 and 18, leftmost > >> > first. > >> > > >> > Using basic 'gpioctl -f /dev/gpioc0 -lv' command I found only > >> > first one, on line 23, reacts. It has value 1 normally and 0 > >> > when pressed. > >> > > >> you must setup the pins as inputs first before using them as > >> inputs. I would not rely on any defaults. > >> > >> Erich > > > > According available docs, all GPIO are set to input mode after > > reset. This seems not to be the case, but that's not my point. What > > was a bit of surprise for me was even 'gpioctl -f /dev/gpioc0 -l' > > tells those pins are in input mode ('pin nn'), it did not work. > > And fact that even after power disconnect the state remains the > > same is even more weird. > > > > Anyway, I accept the necessity for setup, the question is, where > > should these setup instruction go. > > > > Regards, > > Milan > > The GPIO driver do not touch the pin settings at boot, there are a few > things like the LAN reset (GPIO pin 6) where we hope the loader is > doing the right thing. > > Only a few drivers are checking and making sure that the pins they use > have the right settings at boot. > > What I see from PiTFT schematics is that the push buttons doesn't have > any pull-ups resistors, so it must rely on RPi settings. > > Please try the following (set the pin as input with pull-up enabled): > > gpioctl -c 18 in pu > gpioctl -c 21 in pu # or 27 for rev. 2 > gpioctl -c 22 in pu > gpioctl -c 23 in pu > > HTH, > Luiz So, with some experimenting I can confirm this works. And after looking a bit more into available docs I understand it better - even the behavior which surprised me a bit. In BCM2835 ARM peripherals, page 100, GPIO pull-up/down register, second paragraph, second sentence: GPIO pull-ups are maintained even in power down mode when the core is off. So nothing unclear anymore, it just takes a bit of time to find all relevant information bits. Regards, Milan