2009-05-29 18:52:53 GPIO and PFlags
Jeff Tan (UNITED STATES)
Message: 74792
I just upgraded from uclinux 2006R2 to 2008R1.5. I am not familiar with the new GPIO interface and the new dynamic device node creation. Can anyone tell me how do I configure GPIO so that I can access the PF0 and PF9 in my user-space application code?
A step by step instructions on how to make my system create the necessary device nodes and a simple example showing how to access the Pflags would be highly appreciated. Thanks a lot.
QuoteReplyEditDelete
2009-05-29 18:58:23 Re: GPIO and PFlags
Mike Frysinger (UNITED STATES)
Message: 74793
if you use the 2008R1 SVN branch rather than the release, the simple-gpio driver will be integrated for you
QuoteReplyEditDelete
2009-05-29 19:49:23 Re: GPIO and PFlags
Jeff Tan (UNITED STATES)
Message: 74794
I know there is a GPIO option in the menuconfig. But my question was:
How to do access the /dev/PF* in my application code? How do I setup the dynamic device nodes?
Please do not assume that I am an expert. If Analog Device wants to sell more Bfins, I think you really need to improve your support. If you are lazy replying, please do not reply. If you do reply, please be more specific or direct me to the correct documentations!!!
QuoteReplyEditDelete
2009-05-29 20:14:13 Re: GPIO and PFlags
Mike Frysinger (UNITED STATES)
Message: 74795
if you actually described the software you were using instead of asking general questions, you'd probably get better answers
dynamic device nodes are handled for you by default
if you want to know how to use the simple gpio driver, try reading the documentation:
docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:simple-gpio
QuoteReplyEditDelete
2009-06-01 13:19:26 Re: GPIO and PFlags
Jeff Tan (UNITED STATES)
Message: 74925
No, dynamic device nodes are not handled "by default" as you said in uclinux 2008R1.5RC3 - I did not see those /dev/gpio* nodes. After hours of googling, I found that this release use the mdev script at boot time to setup the nodes. I wish Analog Device did a better job putting together the documentation and better support!
I still do not know how to access the PFlags in the new release. In the 2006RC2, I used the device nodes /dev/pf* to manipulate them. In 2008R1.5, I see /dev/gpio0 to /dev/gpio15, but writing to them seems does not change the PFlags. To be more specific, I want to access PF0/SPISS and PF9, how do I do this with the GPIO driver in 2008R1.5RC3? Thanks.
QuoteReplyEditDelete
2009-06-01 14:13:41 Re: GPIO and PFlags
Robin Getz (UNITED STATES)
Message: 74929
Jeff:
It _is_ handled by default if you are using one on the ADI platforms - if you upgraded - and didn't upgrade your vendor files properly - there isn't much we can do about the problems that you are imposing on yourself...
Rather than go down rat holes - can you describe why you are trying to do? Is it just wiggle (output) the pins? or as input? or use them as SPI select?
-Robin
QuoteReplyEditDelete
2009-06-01 15:29:03 Re: GPIO and PFlags
Jeff Tan (UNITED STATES)
Message: 74932
I did use one of the ADI platform - Venders: Analog Devices: BF533-Stamp. If you check the rc file in this vendor tree of 2008R1.5RC3, you will find it does not use the mdev script to setup the nodes. It tooks me hours if not days to figure out how to add the mdev into the rc file to setup the device nodes - not with the help of your documentations but of some article that I googled on the Internet. If only you could put this on your web site or be more specific and detailed in answering questions from users who are not familar with the new release like me!
I have a custom board that use a BF532 CPU that closely resembles the BF533 stamp board. What I want to do is to use the SPI driver with PF0/SPISS as its chip select and PF9 as a control line to talk to our front panel. The SPI is used as a half-duplex interface so that:
1. When the BF SPI writes, our firmware sets the control line PF9 to 0.
2. When the BF SPI reads, our firmware sets the control line PF9 to 1.
3. PF0/SPISS acts as the SPI chip select.
In 2006RC2, I used to the PFlag driver to control PF0 and PF9. In the new release, I do not know how to do this with the GPIO driver - I was told by Mike that the PFlag driver was integrated into the new GPIO driver. But I tried to write to /dev/gpio0 and /dev/gpi09 without success. What should I do?
I believe this should be a pretty simple problem, but I could not find the right way to do it on your web site. The pflag-test program comes with the 2008R1.5 release is not working since it tries to acces /dev/pf* that do not exist any more in the new release. I suggest you remove it if its out of date - broken programs bring more confuse to users.
QuoteReplyEditDelete
2009-06-01 16:26:57 Re: GPIO and PFlags
Mike Frysinger (UNITED STATES)
Message: 74934
the default BF533-STAMP rc file looks just fine to me:
blackfin.uclinux.org/gf/project/uclinux-dist/scmsvn/?action=browse&path=/tags/2008R1.5-RC3/vendors/AnalogDevices/BF533-STAMP/rc&revision=6986
the documentation already clearly covers device management (and mdev):
docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:dev-management
did you actually read the simple-gpio documentation i already pointed you to ?
QuoteReplyEditDelete
2009-06-01 17:03:52 Re: GPIO and PFlags
Jeff Tan (UNITED STATES)
Message: 74935
Yes, I read the gpio documentation. But it does not mention the map between /dev/pf* and /dev/gpio*. I IMPLY that /dev/gpio# is the same as /dev/pf#. Is this true?
As I mentioned, I could not set the PF0 and PF9 via /dev/gpio0 and /dev/gpio9. For example, I did:
1.) echo -n O > /dev/gpio9
2.) echo -n 1 > /dev/gpio9
But the above commands did not set PF9 to high.
QuoteReplyEditDelete
2009-06-01 17:11:34 Re: GPIO and PFlags
Mike Frysinger (UNITED STATES)
Message: 74936
the GPIOs are freed when the device is closed. so you'll have to make sure to not close the fd if you want to keep the settings stable. ive added a note to the documentation about this.
the P?## to GPIO## binding is a linear map with PF0 starting at 0. you can review the interrupts page for the binding:
docs.blackfin.uclinux.org/doku.php?id=linux-kernel:interrupts#gpio_interrupt_processing
QuoteReplyEditDelete
2009-06-02 18:26:15 Re: GPIO and PFlags
Jeff Tan (UNITED STATES)
Message: 75043
This seems to be a bug to me: if I do
echo -n "O1" > /dev/gpio9,
it actually changes the direction of PF9 to input in the FIO_DIR register (bit 9 is set to 0). I think I will write my own driver to control the PFlags.
QuoteReplyEditDelete
2009-06-02 18:39:46 Re: GPIO and PFlags
Mike Frysinger (UNITED STATES)
Message: 75044
no it doesnt. the GPIO was freed after the echo finished just like i said and like the documentation states.
QuoteReplyEditDelete
2009-06-02 19:48:23 Re: GPIO and PFlags
Jeff Tan (UNITED STATES)
Message: 75045
I actually read the FIO_DIR register before and after writing "O1" to gpio0 and gpio9 w/ the GPIO driver. The result was that the corresponding bits were cleared. It seems to me that it has nothing to do with whether the fd is released or not.
QuoteReplyEditDelete
2009-06-02 19:55:35 Re: GPIO and PFlags
Mike Frysinger (UNITED STATES)
Message: 75046
if you want to purpose that course, that's your business