Port-arm archive

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

Re: GPIO API



In this case, the USB-C PHY driver should not access the GPIO directly. Instead, you need to treat it like any other interrupt resource with fdtbus:

 * pinctrl-* defines how the GPIO should be configured to work with this
   device (fdtbus and the platform pinctrl driver will take care of the
   "default" config for you, so nothing to do here)
 * interrupt-parent says that the GPIO controller device provides
   interrupt resources. The selector in interrupts is data for that driver
   to consume.

The Rockchip GPIO driver does not implement support for this today but it shouldn't be difficult to add. You can look at sys/arch/arm/sunxi/sunxi_gpio.c for an example of how to do this (look for fdtbus_register_interrupt_controller).

With that in place, the USB-C PHY driver just needs to call
fdtbus_intr_establish_xname to register a handler for status change events.

HTH,
Jared


On Tue, 25 Jun 2024, Robert Swindells wrote:


Is there a good example to copy on how to setup a GPIO as an input?

I would like to use the USB-C PHY on the Pinebook Pro, it connects to
one pin on the CPU to signal when there is a status change.

I am trying to adapt the fusbtc driver from OpenBSD but their device
tree API is a bit lower level than our one.

The Pinebook Pro device tree has this for the PHY itself:

               fusb30x@22 {
                       compatible = "fcs,fusb302";
                       reg = <0x22>;
                       interrupt-parent = <0x86>;
                       interrupts = <0x02 0x08>;
                       pinctrl-names = "default";
                       pinctrl-0 = <0x87>;
                       vbus-supply = <0x88>;
                       phandle = <0x8e>;

then a pin definition of:

		fusb302x {
                       fusb0-int-pin {
                               rockchip,pins = <0x01 0x02 0x00 0xbf>;
                               phandle = <0x87>;
                       };
               };

Is this enough to be able to use fdtbus_gpio_acquire()?

Also, has anyone done any thinking on how to extend the API to get
GPIO inputs wired up to interrupts?

Robert Swindells




Home | Main Index | Thread Index | Old Index