Re: gpib_bitbang: problem with GPIO tables

dave penkler <[email protected]> Wed, 28 Aug 2024 15:37:58 +0200
Newsgroups gmane.linux.hardware.gpib.general
Message-ID <CAL=kjP2ahGQ8UKYp0XOX38GC9t+6=dXMJBJi2+o12jVJez-P3w@mail.gmail.com>
Hi,
The tables come from the different RPi device trees. Earlier Pi3A+, Pi3B+
based on bcm2837 had the same DT as Pi2B based on bcm2836 but with gpio14
and 15 called TXD1 and RXD1 instead of TXD0 and RXD0 as for the Pi2B. The
bcm2710 and bcm2711 are all like table index 2. As we have no clean way to
test what system we are running on we try the three different tables from
the oldest to newest.
cheers,
-Dave

On Mon, 26 Aug 2024 at 14:20, Michael Schwingen <[email protected]>
wrote:

> Hi,
>
> since the conversion of gpib_bitbang to gpiod lookup tables for GPIO
> allocation (which I think is a good idea, since it gets rid of the
> gpio_offset hack), I am having (slight) problems, since some GPIOs are not
> found on my Pi 3B.
>
> The previous version (2ab64102a655fe183cf9653ab20b0511e95159fb) would
> simply
> fail on my RP3B due to "SPI_MISO" not being found. Using the RP5 table on
> my RP3B fixed this.
>
> The current code does this on its own: allocating SPI_MISO fails, and the
> code tries further tables until the RP45 table works - however, this raises
> the question why there is a separate table for RP3 if it does not work on a
> RP3B?
>
>
> Raspberry Pi 3B, git c2c696d3cb6a3bb81974688a85cdf40a815a9f7c
>
> [    0.000000] Linux version 6.6.31+rpt-rpi-v7 ([email protected])
> (gcc-12 (Raspbian 12.2.0-14+rpi1) 12.2.0, GNU ld (GNU Binutils for
> Raspbian) 2.40) #1 SMP Raspbian 1:6.6.31-1+rpt1 (2024-05-29)
> [    0.000000] CPU: ARMv7 Processor [410fd034] revision 4 (ARMv7),
> cr=10c5383d
>
> [11692.014745] Linux-GPIB 4.3.6 Driver
> [11692.032150] gpib: registered gpib_bitbang interface
> [11692.032174] gpib_bitbang:bb_init_module - module loaded with pin map
> "yoga"
> [11693.087510] gpib_bitbang:bb_attach - Using pin map "yoga"
> [11693.087545] gpib_bitbang:allocate_gpios - Allocating gpios using table
> index 0
> [11693.087562] gpib_bitbang:allocate_gpios - Allocating gpio GPIO20 pin no
> 20
> [11693.087607] gpib_bitbang:allocate_gpios - Allocating gpio GPIO26 pin no
> 26
> [11693.087633] gpib_bitbang:allocate_gpios - Allocating gpio GPIO13 pin no
> 13
> [11693.087658] gpib_bitbang:allocate_gpios - Allocating gpio GPIO12 pin no
> 12
> [11693.087681] gpib_bitbang:allocate_gpios - Allocating gpio GPIO21 pin no
> 21
> [11693.087705] gpib_bitbang:allocate_gpios - Allocating gpio GPIO19 pin no
> 19
> [11693.087729] gpib_bitbang:allocate_gpios - Allocating gpio GPIO6 pin no 6
> [11693.087751] gpib_bitbang:allocate_gpios - Allocating gpio GPIO5 pin no 5
> [11693.087773] gpib_bitbang:allocate_gpios - Allocating gpio GPIO9 pin no 9
> [11693.087796] gpib_common gpib0: cannot find GPIO line SPI_MISO, deferring
> [11693.087811] gpib_bitbang:allocate_gpios - Allocation failed,  now
> using table_index 1
> [11693.087823] gpib_bitbang:allocate_gpios - Allocating gpio GPIO9 pin no 9
> [11693.087840] gpib_common gpib0: cannot find GPIO line SPI_MISO, deferring
> [11693.087853] gpib_bitbang:allocate_gpios - Allocation failed,  now
> using table_index 2
> [11693.087864] gpib_bitbang:allocate_gpios - Allocating gpio GPIO9 pin no 9
> [11693.087887] gpib_bitbang:allocate_gpios - Allocating gpio GPIO24 pin no
> 24
> [11693.087911] gpib_bitbang:allocate_gpios - Allocating gpio GPIO22 pin no
> 22
> [11693.087935] gpib_bitbang:allocate_gpios - Allocating gpio GPIO25 pin no
> 25
> [11693.087959] gpib_bitbang:allocate_gpios - Allocating gpio GPIO27 pin no
> 27
> [11693.087983] gpib_bitbang:allocate_gpios - Allocating gpio GPIO10 pin no
> 10
> [11693.088005] gpib_bitbang:allocate_gpios - Allocating gpio GPIO23 pin no
> 23
> [11693.088029] gpib_bitbang:allocate_gpios - Allocating gpio GPIO11 pin no
> 11
> [11693.088052] gpib_bitbang:allocate_gpios - Allocating gpio GPIO18 pin no
> 18
> [11693.088172] gpib_bitbang:bb_attach - attached board 0
>
> gpioinfo shows:
>
> gpiochip0 - 54 lines:
>         line   0:     "ID_SDA"       unused   input  active-high
>         line   1:     "ID_SCL"       unused   input  active-high
>         line   2:      "GPIO2"       unused   input  active-high
>         line   3:      "GPIO3"       unused   input  active-high
>         line   4:      "GPIO4"    "hat_led"  output  active-high [used]
>         line   5:      "GPIO5"      "GPIO5"  output  active-high [used]
>         line   6:      "GPIO6"      "GPIO6"  output  active-high [used]
>         line   7:      "GPIO7"       unused   input  active-high
>         line   8:      "GPIO8"       unused   input  active-high
>         line   9:      "GPIO9"      "GPIO9"  output  active-high [used]
>         line  10:     "GPIO10"     "GPIO10"  output  active-high [used]
>         line  11:     "GPIO11"     "GPIO11"   input  active-high [used]
>         line  12:     "GPIO12"     "GPIO12"  output  active-high [used]
>         line  13:     "GPIO13"     "GPIO13"  output  active-high [used]
>         line  14:     "GPIO14"       unused   input  active-high
>         line  15:     "GPIO15"       unused   input  active-high
>         line  16:     "GPIO16"       unused   input  active-high
>         line  17:     "GPIO17"       unused   input  active-high
>         line  18:     "GPIO18"     "GPIO18"  output  active-high [used]
>         line  19:     "GPIO19"     "GPIO19"  output  active-high [used]
>         line  20:     "GPIO20"     "GPIO20"  output  active-high [used]
>         line  21:     "GPIO21"     "GPIO21"  output  active-high [used]
>         line  22:     "GPIO22"     "GPIO22"  output  active-high [used]
>         line  23:     "GPIO23"     "GPIO23"   input  active-high [used]
>         line  24:     "GPIO24"     "GPIO24"   input  active-high [used]
>         line  25:     "GPIO25"     "GPIO25"   input  active-high [used]
>         line  26:     "GPIO26"     "GPIO26"  output  active-high [used]
>         line  27:     "GPIO27"     "GPIO27"  output  active-high [used]
>         line  28: "HDMI_HPD_N"        "hpd"   input   active-low [used]
>         line  29: "STATUS_LED_G" "ACT" output active-high [used]
>         line  30:       "CTS0"       unused   input  active-high
>         line  31:       "RTS0"       unused   input  active-high
>         line  32:       "TXD0"       unused   input  active-high
>         line  33:       "RXD0"       unused   input  active-high
>         line  34:    "SD1_CLK"       unused   input  active-high
>         line  35:    "SD1_CMD"       unused   input  active-high
>         line  36:  "SD1_DATA0"       unused   input  active-high
>         line  37:  "SD1_DATA1"       unused   input  active-high
>         line  38:  "SD1_DATA2"       unused   input  active-high
>         line  39:  "SD1_DATA3"       unused   input  active-high
>         line  40:   "PWM0_OUT"       unused   input  active-high
>         line  41:   "PWM1_OUT"       unused   input  active-high
>         line  42:    "ETH_CLK"       unused   input  active-high
>         line  43:   "WIFI_CLK"       unused   input  active-high
>         line  44:       "SDA0"       unused   input  active-high
>         line  45:       "SCL0"       unused   input  active-high
>         line  46:   "SMPS_SCL"       unused   input  active-high
>         line  47:   "SMPS_SDA"       unused  output  active-high
>         line  48:   "SD_CLK_R"       unused   input  active-high
>         line  49:   "SD_CMD_R"       unused   input  active-high
>         line  50: "SD_DATA0_R"       unused   input  active-high
>         line  51: "SD_DATA1_R"       unused   input  active-high
>         line  52: "SD_DATA2_R"       unused   input  active-high
>         line  53: "SD_DATA3_R"       unused   input  active-high
> gpiochip1 - 8 lines:
>         line   0:      "BT_ON"       unused  output  active-high
>         line   1:      "WL_ON"       unused  output  active-high
>         line   2:  "PWR_LED_R"        "PWR"  output   active-low [used]
>         line   3:    "LAN_RUN"       unused  output  active-high
>         line   4:         "NC"       unused   input  active-high
>         line   5:  "CAM_GPIO0" "cam1_regulator" output active-high [used]
>         line   6:  "CAM_GPIO1"       unused  output  active-high
>         line   7:         "NC"       unused   input  active-high
>
>
> Where do these gpio_gpib_* tables come from?  It looks to me like we should
> be able to use generic names ("GPIO9" instead of "SPI_MISO") for all
> machines (ie.  simply use the rp45 table), since they are in the device
> tree
> - but I am no expert on this.  Are these different depending on OS version?
>
> Looking at the device tree files shows generic names (eg. GPIO9 instead of
> SPI_MISO):
>
> dtc -I dtb -O dts  /boot/firmware/bcm2711-rpi-4-b.dtb | grep
> gpio-line-names
> gpio-line-names =
> "ID_SDA\0ID_SCL\0GPIO2\0GPIO3\0GPIO4\0GPIO5\0GPIO6\0GPIO7\0GPIO8\0GPIO9\0GPIO10\0GPIO11\0GPIO12\0GPIO13\0GPIO14\0GPIO15\0GPIO16\0GPIO17\0GPIO18\0GPIO19\0GPIO20\0GPIO21\0GPIO22\0GPIO23\0GPIO24\0GPIO25\0GPIO26\0GPIO27\0RGMII_MDIO\0RGMIO_MDC\0CTS0\0RTS0\0TXD0\0RXD0\0SD1_CLK\0SD1_CMD\0SD1_DATA0\0SD1_DATA1\0SD1_DATA2\0SD1_DATA3\0PWM0_MISO\0PWM1_MOSI\0STATUS_LED_G_CLK\0SPIFLASH_CE_N\0SDA0\0SCL0\0RGMII_RXCLK\0RGMII_RXCTL\0RGMII_RXD0\0RGMII_RXD1\0RGMII_RXD2\0RGMII_RXD3\0RGMII_TXCLK\0RGMII_TXCTL\0RGMII_TXD0\0RGMII_TXD1\0RGMII_TXD2\0RGMII_TXD3";
>
> dtc -I dtb -O dts  /boot/firmware/bcm2710-rpi-3-b.dtb | grep
> gpio-line-names
> gpio-line-names =
> "ID_SDA\0ID_SCL\0GPIO2\0GPIO3\0GPIO4\0GPIO5\0GPIO6\0GPIO7\0GPIO8\0GPIO9\0GPIO10\0GPIO11\0GPIO12\0GPIO13\0GPIO14\0GPIO15\0GPIO16\0GPIO17\0GPIO18\0GPIO19\0GPIO20\0GPIO21\0GPIO22\0GPIO23\0GPIO24\0GPIO25\0GPIO26\0GPIO27\0NC\0LAN_RUN_BOOT\0CTS0\0RTS0\0TXD0\0RXD0\0SD1_CLK\0SD1_CMD\0SD1_DATA0\0SD1_DATA1\0SD1_DATA2\0SD1_DATA3\0PWM0_OUT\0PWM1_OUT\0ETH_CLK\0WIFI_CLK\0SDA0\0SCL0\0SMPS_SCL\0SMPS_SDA\0SD_CLK_R\0SD_CMD_R\0SD_DATA0_R\0SD_DATA1_R\0SD_DATA2_R\0SD_DATA3_R";
>
> dtc -I dtb -O dts  /boot/firmware/bcm2710-rpi-2-b.dtb | grep
> gpio-line-names
> gpio-line-names =
> "ID_SDA\0ID_SCL\0GPIO2\0GPIO3\0GPIO4\0GPIO5\0GPIO6\0GPIO7\0GPIO8\0GPIO9\0GPIO10\0GPIO11\0GPIO12\0GPIO13\0GPIO14\0GPIO15\0GPIO16\0GPIO17\0GPIO18\0GPIO19\0GPIO20\0GPIO21\0GPIO22\0GPIO23\0GPIO24\0GPIO25\0GPIO26\0GPIO27\0SDA0\0SCL0\0NC\0LAN_RUN\0CAM_GPIO1\0NC\0NC\0PWR_LOW_N\0NC\0NC\0USB_LIMIT\0NC\0PWM0_OUT\0CAM_GPIO0\0SMPS_SCL\0SMPS_SDA\0ETH_CLK\0PWM1_OUT\0HDMI_HPD_N\0STATUS_LED\0SD_CLK_R\0SD_CMD_R\0SD_DATA0_R\0SD_DATA1_R\0SD_DATA2_R\0SD_DATA3_R";
>
> cu
> Michael
>
>
> _______________________________________________
> Linux-gpib-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/linux-gpib-general
>

_______________________________________________
Linux-gpib-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-gpib-general