Re: [PATCHv4 2/2] Add a GPIO driver for Altera FPGA Manager Fabric I/O

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/20/17 10:10, Linus Walleij wrote:
> On Thu, Oct 19, 2017 at 6:29 PM, Bernd Edlinger
> <bernd.edlinger@xxxxxxxxxx> wrote:
> 
> Does this really work?
> 

Yes, it does really work.

I use it to gate a clock signal using fpga logic
instead of an external and gate on the PCB.

And another driver uses this gpio which
is configured as "select-gpio = <&portd 2 0>;"
in the device tree.  The actual I/O is simply
controlled with gpiod_set_value(), which works
without the other driver ever knowing how the
I/O is connected.

I was also able to exercise the device unload code path,
using your hint with the gpio unbind file in the sysfs.

>> This is an internal 32-bit input and 32-bit output port to the FPGA logic.
>>
>> Instantiate this in the device tree as:
>>
>>    gpio3: gpio@ff706010 {
>>     #address-cells = <1>;
>>     #size-cells = <0>;
>>     compatible = "altr,fpgamgr-gpio";
>>     reg = <0xff706010 0x8>;
>>     status = "okay";
>>
>>     portd: gpio-controller@0 {
>>      compatible = "altr,fpgamgr-gpio-output";
>>      gpio-controller;
>>      #gpio-cells = <2>;
>>      reg = <0>;
>>     };
>>
>>     porte: gpio-controller@1 {
>>      compatible = "altr,fpgamgr-gpio-input";
>>      gpio-controller;
>>      #gpio-cells = <2>;
>>      reg = <1>;
>>     };
> 
> So you have output-only and input-only ports....
> 

Yes.

>> +static int fpgamgr_gpio_add_port(struct fpgamgr_gpio *gpio,
>> +                                struct fpgamgr_port_property *pp,
>> +                                unsigned int offs)
>> +{
>> +       struct fpgamgr_gpio_port *port;
>> +       void __iomem *dat;
>> +       int err;
>> +
>> +       port = &gpio->ports[offs];
>> +       port->gpio = gpio;
>> +       port->idx = pp->idx;
>> +
>> +       dat = gpio->regs + (pp->idx * 4);
>> +
>> +       err = bgpio_init(&port->bgc, gpio->dev, 4, dat, NULL, NULL,
>> +                        NULL, NULL, 0);
> 
> But all you add is input-only GPIO chips. Also for the output ports.
> 

Well actually this allows both input and output,
but while the input port could be written by accident,
the hardware does the right thing and ignores the write cycle.

The other parameters of bgpio_input are for devices with
explicit set- and reset-signals, and configurable
output-direction etc, which I don't have.



Bernd.
��.n��������+%������w��{.n����z�{��ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux