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

Bug#1032042: linux: gpio in falling-edge mode returns both falling /and/ rising edge events and /both/ are tagged as falling [Raspberry Pi Zero W, usb-host]



Package: linux-image-5.10.0-18-rpi
Version: 5.10.140-1
Severity: normal
Tags: upstream

Dear Maintainer,

In my application, I have hard-wired a USB device,
and would like to run the USB controller in host mode
to avoid needing the OTG ID pin.

On Foundation systems this is the default, and OTG mode is only enabled
with dtoverlay=dwc2 in config.txt; the upstream device trees, which
Debian uses, use OTG by default since
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bcc76c4014dce4e3834dbd5b7f6593cbcfbfebe0

To that end, I applied the following, effectively reverting that:
-- >8 --
$ diff -u ./arch/arm/boot/dts/bcm2835-rpi-zero-w.dts{.orig,}
--- ./arch/arm/boot/dts/bcm2835-rpi-zero-w.dts.orig     2023-02-26 21:44:40.206721896 +0100
+++ ./arch/arm/boot/dts/bcm2835-rpi-zero-w.dts  2023-02-26 21:44:50.919200574 +0100
@@ -6,7 +6,7 @@
 /dts-v1/;
 #include "bcm2835.dtsi"
 #include "bcm2835-rpi.dtsi"
-#include "bcm283x-rpi-usb-otg.dtsi"
+#include "bcm283x-rpi-usb-host.dtsi"

 / {
        compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
-- >8 --
and built the device tree.
(I also did that to the 6.2-rc1 device tree as a test,
 and they function identically.)

This does work, inasmuch as the device is enumerated, but in my
application I also use GPIO in GPIO_V2_LINE_FLAG_INPUT |
GPIO_V2_LINE_FLAG_BIAS_PULL_UP | GPIO_V2_LINE_FLAG_EDGE_FALLING mode
(or, per lsgpio
        line  5: "GPIO5" "ORNO-OR-WE-505-gpio.c" [used, input, pull-up, falling-edge]
        line  6: "GPIO6" "ORNO-OR-WE-505-gpio.c" [used, input, pull-up, falling-edge]
 ).

The GPIO lines are shorted to ground temporarily, then are let float.
Please consult the following diagram w.r.t. what happens
(for simplicity, I described the pulses as 1Hz/36ms, that doesn't matter).

	time	line	correct	host	both
	0s	3.3V			
	1s	0	falling	falling	falling
	1s36ms	3.3V		falling	rising
	2s	0	falling	falling	falling
	2s36ms	3.3V		falling	rising

Wherein "correct" is what I observe with the upstream firmware (usb-otg),
        "host"                      with the usb-hostised firmware,
    and "both"                      with either firmware if I subscribe
                                    to GPIO_V2_LINE_FLAG_INPUT |
                                    GPIO_V2_LINE_FLAG_BIAS_PULL_UP |
                                    GPIO_V2_LINE_FLAG_EDGE_FALLING |
                                    GPIO_V2_LINE_FLAG_EDGE_RISING
                                    ("[used, input, pull-up,
                                       both-edges]" in lsgpio parlance)

So, in short, "in usb-host mode, when subscribed to falling edges,
both edges are returned, but labelled as falling" I guess?

Will try to update to a sid kernel and see what falls out.

Best,
наб

-- System Information:
/etc/raspi-image-id:
	image based on revision: 7dcbdbc (Drop the builds for Buster, 2021-12-06) and build on 2022-10-12 12:35 (UTC)

Raspberry Pi Zero W

Attachment: signature.asc
Description: PGP signature


Reply to: