Issue migration of MCP23S08 from Jetpack-4.x.y to Jetpack-5.0.1

Dear L4T Experts,

Currently I am porting the driver of our camera board in which there’s Microchip IO-Expander (MCP23S08) for expanding controlling signals such as reset, power-down and below is the patch for tegra_defconfig :

diff --git a/kernel/kernel-5.10/arch/arm64/configs/defconfig b/kernel/kernel-5.10/arch/arm64/configs/defconfig
index f97856a59..d1fb61415 100644
--- a/kernel/kernel-5.10/arch/arm64/configs/defconfig
+++ b/kernel/kernel-5.10/arch/arm64/configs/defconfig
@@ -743,6 +743,7 @@ CONFIG_PINCTRL_TEGRA186_DPAUX=y
 CONFIG_PINCTRL_TEGRA234_DPAUX=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_PINCTRL_MAX77620=y
-CONFIG_GPIO_MCP23S08=y
+CONFIG_PINCTRL_MCP23S08=y
 CONFIG_GPIO_SYSFS=y
 CONFIG_GPIO_MB86S7X=y
 CONFIG_GPIO_PCA953X=y

And device-tree nodes :
IO-Expander node:

                mcp23008_27: gpio@27 {
                        compatible = "microchip,mcp23008";
                        gpio-controller;
                        #gpio-cells = <2>;
                        reg = <0x27>;
                        status = "okay";

                        interrupt-parent = <&tegra_aon_gpio>;
                        interrupts = <TEGRA194_AON_GPIO(CC, 3) IRQ_TYPE_EDGE_FALLING>;
                        irq-gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 3) GPIO_ACTIVE_HIGH>;
                        reset-gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Q, 3) GPIO_ACTIVE_HIGH>;
                        interrupt-controller;
                        #interrupt-cells=<2>;
                        microchip,irq-mirror;
                        microchip,irq-active-high;

                        mcp23008_27_output_low {
                                status = "disabled";
                        };

                        mcp23008_27_output_high {
                                gpio-hog;
                                output-high;
                                gpios = <1 0 2 0 3 0>;
                                label = "ioexp_adv_3v3_en", "ioexp_adv_reset", "ioexp_sony_reset";
                        };
                };

Camera node :

                adv7280_e@20 {
                        compatible = "adi,adv7280-m";

                        /* I2C device address */
                        reg = <0x20>;

                        /* V4L2 device node location */
                        devnode = "video1";

                        ....

                        reset-gpios = <&mcp23008_27 2 GPIO_ACTIVE_LOW>;

                        ....
                };

In kernel/nvidia/drivers/media/i2c/adv7280.c :

       priv->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
                                                   GPIOD_OUT_HIGH);
        if (IS_ERR(priv->reset_gpio)) {
                ret = PTR_ERR(priv->reset_gpio);
                v4l_err(client, "request for reset pin failed: %d\n", ret);
                return ret;
        }

But I got following error :
[ 13.486508] adv7280 8-0020: request for reset pin failed: -517

Meanwhile I was working perfectly in Jetpack-4.x.y

Could you help to point out what was missing, please ?

Thanks in advance and best regards,
K.

Sorry for the late response, have you managed to get issue resolved or still need the support? Thanks

Hi @kayccc ,
Unfortunately I haven’t resolved the issue yet!

hello khang.l4es,

the issue should be GPIO allocation range has changed since k-5.10.

do you know which pin you’re going to control?
please refer to developer guide, To check a GPIO number to examine the GPIO number for k-5.10
thanks

Hi @JerryChang ,

Does GPIO allocation range change have effect on GPIOs behind IO-expander as well ? Or does it have effect on the Tegra gpios that are used to control the IO-expander such as below ?

                       interrupt-parent = <&tegra_aon_gpio>;
                        interrupts = <TEGRA194_AON_GPIO(CC, 3) IRQ_TYPE_EDGE_FALLING>;
                        irq-gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 3) GPIO_ACTIVE_HIGH>;
                        reset-gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Q, 3) GPIO_ACTIVE_HIGH>;

Best Regards,
K.

hello khang.l4es,

hold-on, are you still using JetPack-5.0.1? this is for development only.
please moving to JetPack 5.0.2 production release version. thanks

1 Like

Hi @kayccc and @JerryChang ,

I pumped the system to Jetpack-5.0.2-R35.1 :

rtr@ubuntu:~$ uname -ra
Linux ubuntu 5.10.104 #1 SMP PREEMPT Tue Nov 8 11:28:57 +07 2022 aarch64 aarch64 aarch64 GNU/Linux

and had the same issue.

[   11.118530] adv7280 8-0020: request for reset pin failed: -517

Below is the info of GPIO mapping :

rtr@ubuntu:~$ sudo cat /sys/kernel/debug/gpio
gpiochip2: GPIOs 305-334, parent: platform/c2f0000.gpio, tegra194-gpio-aon:
 gpio-305 (PAA.00              )
 gpio-306 (PAA.01              )
 gpio-307 (PAA.02              )
 gpio-308 (PAA.03              )
 gpio-309 (PAA.04              )
 gpio-310 (PAA.05              )
 gpio-311 (PAA.06              )
 gpio-312 (PAA.07              )
 gpio-313 (PBB.00              )
 gpio-314 (PBB.01              )
 gpio-315 (PBB.02              )
 gpio-316 (PBB.03              )
 gpio-317 (PCC.00              )
 gpio-318 (PCC.01              |pwr                 ) out hi 
 gpio-319 (PCC.02              )
 gpio-320 (PCC.03              )
 gpio-321 (PCC.04              )
 gpio-322 (PCC.05              )
 gpio-323 (PCC.06              )
 gpio-324 (PCC.07              )
 gpio-325 (PDD.00              )
 gpio-326 (PDD.01              )
 gpio-327 (PDD.02              )
 gpio-328 (PEE.00              )
 gpio-329 (PEE.01              )
 gpio-330 (PEE.02              )
 gpio-331 (PEE.03              )
 gpio-332 (PEE.04              |power-key           ) in  hi IRQ ACTIVE LOW
 gpio-333 (PEE.05              )
 gpio-334 (PEE.06              )
gpiochip1: GPIOs 335-503, parent: platform/2200000.gpio, tegra194-gpio:
 gpio-335 (PA.00               )
 gpio-336 (PA.01               )
 gpio-337 (PA.02               )
 gpio-338 (PA.03               )
 gpio-339 (PA.04               )
 gpio-340 (PA.05               )
 gpio-341 (PA.06               )
 gpio-342 (PA.07               )
 gpio-343 (PB.00               )
 gpio-344 (PB.01               )
 gpio-345 (PC.00               )
 gpio-346 (PC.01               )
 gpio-347 (PC.02               )
 gpio-348 (PC.03               )
 gpio-349 (PC.04               )
 gpio-350 (PC.05               )
 gpio-351 (PC.06               )
 gpio-352 (PC.07               )
 gpio-353 (PD.00               )
 gpio-354 (PD.01               )
 gpio-355 (PD.02               )
 gpio-356 (PD.03               )
 gpio-357 (PE.00               )
 gpio-358 (PE.01               )
 gpio-359 (PE.02               )
 gpio-360 (PE.03               )
 gpio-361 (PE.04               )
 gpio-362 (PE.05               )
 gpio-363 (PE.06               )
 gpio-364 (PE.07               )
 gpio-365 (PF.00               )
 gpio-366 (PF.01               )
 gpio-367 (PF.02               )
 gpio-368 (PF.03               )
 gpio-369 (PF.04               )
 gpio-370 (PF.05               )
 gpio-371 (PG.00               |force-recovery      ) in  hi IRQ ACTIVE LOW
 gpio-372 (PG.01               )
 gpio-373 (PG.02               |fixed-regulators:reg) out lo 
 gpio-374 (PG.03               |wifi-enable         ) out hi 
 gpio-375 (PG.04               )
 gpio-376 (PG.05               |phy_reset           ) out hi 
 gpio-377 (PG.06               )
 gpio-378 (PG.07               )
 gpio-379 (PH.00               )
 gpio-380 (PH.01               )
 gpio-381 (PH.02               )
 gpio-382 (PH.03               )
 gpio-383 (PH.04               )
 gpio-384 (PH.05               )
 gpio-385 (PH.06               )
 gpio-386 (PH.07               )
 gpio-387 (PI.00               )
 gpio-388 (PI.01               )
 gpio-389 (PI.02               )
 gpio-390 (PI.03               )
 gpio-391 (PI.04               )
 gpio-392 (PJ.00               )
 gpio-393 (PJ.01               )
 gpio-394 (PJ.02               )
 gpio-395 (PJ.03               )
 gpio-396 (PJ.04               )
 gpio-397 (PJ.05               )
 gpio-398 (PK.00               )
 gpio-399 (PK.01               )
 gpio-400 (PK.02               )
 gpio-401 (PK.03               )
 gpio-402 (PK.04               )
 gpio-403 (PK.05               )
 gpio-404 (PK.06               )
 gpio-405 (PK.07               )
 gpio-406 (PL.00               )
 gpio-407 (PL.01               )
 gpio-408 (PL.02               )
 gpio-409 (PL.03               )
 gpio-410 (PM.00               )
 gpio-411 (PM.01               |hdmi2.0_hpd         ) in  lo IRQ 
 gpio-412 (PM.02               )
 gpio-413 (PM.03               )
 gpio-414 (PM.04               )
 gpio-415 (PM.05               )
 gpio-416 (PM.06               )
 gpio-417 (PM.07               )
 gpio-418 (PN.00               |fixed-regulators:reg) out lo 
 gpio-419 (PN.01               )
 gpio-420 (PN.02               )
 gpio-421 (PO.00               )
 gpio-422 (PO.01               )
 gpio-423 (PO.02               )
 gpio-424 (PO.03               )
 gpio-425 (PO.04               )
 gpio-426 (PO.05               )
 gpio-427 (PP.00               )
 gpio-428 (PP.01               )
 gpio-429 (PP.02               )
 gpio-430 (PP.03               )
 gpio-431 (PP.04               )
 gpio-432 (PP.05               )
 gpio-433 (PP.06               )
 gpio-434 (PP.07               )
 gpio-435 (PQ.00               )
 gpio-436 (PQ.01               )
 gpio-437 (PQ.02               )
 gpio-438 (PQ.03               )
 gpio-439 (PQ.04               )
 gpio-440 (PQ.05               )
 gpio-441 (PQ.06               )
 gpio-442 (PQ.07               )
 gpio-443 (PR.00               )
 gpio-444 (PR.01               )
 gpio-445 (PR.02               )
 gpio-446 (PR.03               )
 gpio-447 (PR.04               )
 gpio-448 (PR.05               )
 gpio-449 (PS.00               )
 gpio-450 (PS.01               )
 gpio-451 (PS.02               )
 gpio-452 (PS.03               )
 gpio-453 (PS.04               )
 gpio-454 (PS.05               )
 gpio-455 (PS.06               )
 gpio-456 (PS.07               )
 gpio-457 (PT.00               )
 gpio-458 (PT.01               )
 gpio-459 (PT.02               )
 gpio-460 (PT.03               )
 gpio-461 (PT.04               )
 gpio-462 (PT.05               )
 gpio-463 (PT.06               )
 gpio-464 (PT.07               )
 gpio-465 (PU.00               )
 gpio-466 (PV.00               )
 gpio-467 (PV.01               )
 gpio-468 (PV.02               )
 gpio-469 (PV.03               )
 gpio-470 (PV.04               )
 gpio-471 (PV.05               )
 gpio-472 (PV.06               )
 gpio-473 (PV.07               )
 gpio-474 (PW.00               )
 gpio-475 (PW.01               )
 gpio-476 (PX.00               )
 gpio-477 (PX.01               )
 gpio-478 (PX.02               )
 gpio-479 (PX.03               )
 gpio-480 (PX.04               )
 gpio-481 (PX.05               )
 gpio-482 (PX.06               )
 gpio-483 (PX.07               )
 gpio-484 (PY.00               )
 gpio-485 (PY.01               )
 gpio-486 (PY.02               )
 gpio-487 (PY.03               )
 gpio-488 (PY.04               )
 gpio-489 (PY.05               )
 gpio-490 (PY.06               )
 gpio-491 (PY.07               )
 gpio-492 (PZ.00               )
 gpio-493 (PZ.01               |vbus                ) in  lo IRQ ACTIVE LOW
 gpio-494 (PZ.02               )
 gpio-495 (PZ.03               )
 gpio-496 (PZ.04               )
 gpio-497 (PZ.05               )
 gpio-498 (PZ.06               )
 gpio-499 (PZ.07               )
 gpio-500 (PFF.00              )
 gpio-501 (PFF.01              )
 gpio-502 (PGG.00              )
 gpio-503 (PGG.01              )

gpiochip0: GPIOs 504-511, parent: i2c/4-003c, max77620-gpio, can sleep:
 gpio-510 (                    |gpio_default        ) in  hi 
 gpio-511 (                    |gpio_default        ) in  hi 

Looks like there’s no info related to any mcp23s08. What would be missing?
K.

hello khang.l4es,

GPIO allocation range changes it affect the Tegra GPIOs used to control the IO-expander.

BTW,
what these three GPIOs you’re actually used.
could you please specify them by marco, i.e. TEGRA194_MAIN_GPIO(...) for testing?

Hi @JerryChang ,
Possibly I don’t understand well you idea but the tegra GPIO signals used to control the IO-Expander are all defined within the device-tree node :

                        interrupt-parent = <&tegra_aon_gpio>;
                        interrupts = <TEGRA194_AON_GPIO(CC, 3) IRQ_TYPE_EDGE_FALLING>;
                        irq-gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 3) GPIO_ACTIVE_HIGH>;
                        reset-gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Q, 3) GPIO_ACTIVE_HIGH>;

Concretely, the irq-gpios and reset-gpios stay same as in Jetpack-4.5.x. The camera node (adv7280) is then controlled by output #2 of the IO-Expander and labelled with ioexp_adv_reset.

Did you mean that I should re-work on the definition of irq-gpios and reset-gpios so that the IO-Expander will be correctly controlled as the macros (such as TEGRA194_AON_GPIO/ TEGRA194_MAIN_GPIO) and / or the arguments of the marcros (such as (CC, 3)/ (Q 3)) are not correct anymore in newer Kernel/BSP?

Regards,
K.

hello khang.l4es,

[edit] that’s incorrect, please ignore them.


I meant revise the code as below…
mcp23008_27_output_high {
gpios = <TEGRA194_MAIN_GPIO(…) 0
TEGRA194_MAIN_GPIO(…) 0

Hi @JerryChang,

Sorry but I do not understand why should TEGRA194_MAIN_GPIO macros be added to the gpios array which are outputs of the MCP23008 IO Expander. I found similar example of TCA6408 in the following dtsi which does not use any macro:

$ vi hardware/nvidia/platform/t19x/mccoy/kernel-dts/common/tegra194-e3900-0000-camera-e3333-a00.dtsi +38
        i2c@3180000 {
                tca6408_21: tca6408@21 {
                        compatible = "ti,tca6408";
                        gpio-controller;
                        #gpio-cells = <2>;
                        reg = <0x21>;
                        vcc-supply = <&e3900_sys_1v8_cvb>;
                        tca6408_21_outlow {
                                /*
                                 * GPIO-0 : PWDN_CAM2
                                 * GPIO-1 : RST_CAM2
                                 * GPIO-2 : PWDN_CAM3
                                 * GPIO-3 : RST_CAM3
                                 * GPIO-4 : PWDN_CAM4
                                 * GPIO-5 : RST_CAM4
                                 * GPIO-6 : PWDN_CAM5
                                 * GPIO-7 : RST_CAM5
                                 */
                                gpio-hog;
                                gpios = <0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0>;
                                output-low;
                                label = "tca6408_21_outlow_0",
                                        "tca6408_21_outlow_1",
                                        "tca6408_21_outlow_2",
                                        "tca6408_21_outlow_3",
                                        "tca6408_21_outlow_4",
                                        "tca6408_21_outlow_5",
                                        "tca6408_21_outlow_6",
                                        "tca6408_21_outlow_7";
                        };
                        tca6408_21_outhigh {
                                status = "disabled";
                        };
                        tca6408_21_input {
                                status = "disabled";
                        };
                };

Hi @JerryChang :

Some new clue:

[    7.571275] gpio-298 (mcp23008_27_output_high): hogged as output/high
[    7.572398] gpio-299 (mcp23008_27_output_high): hogged as output/high
[    7.573405] gpio-300 (mcp23008_27_output_high): hogged as output/high
[    7.574008] gpiochip3: registered GPIOs 297 to 304 on mcp23008
[    7.589172] mcp230xx 8-0027: unable to request IRQ#263: -5
[    7.594198] mcp230xx 8-0027: error -5: can't setup IRQ
[    7.600428] mcp230xx: probe of 8-0027 failed with error -5

Regards,
K.

Hi @JerryChang ,

From your comments JetPack5 GPIO Assignments in NX Module - #5 by JerryChang, How to know the port number the board and system device name - #5 by JerryChang and GPIO, SPI and PWM not working on Jetson Xavier NX - #25 by JerryChang, does it mean that TEGRA194_MAIN_GPIO or TEGRA194_AON_GPIO should not be used anymore in Kernel 5.10 as they give incorrect number and the GPIO number should be used directly ?
Concretely, instead of using :

                       interrupts = <TEGRA194_AON_GPIO(CC, 3) IRQ_TYPE_EDGE_FALLING>;
                       irq-gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 3) GPIO_ACTIVE_HIGH>;

I should use :

                       interrupts = <320 IRQ_TYPE_EDGE_FALLING>;
                       irq-gpios = <&tegra_aon_gpio 320 GPIO_ACTIVE_HIGH>;

with 320 taken from :

gpio-320 (PCC.03              )

What is your opinion?

Best Regards,
K

Hi @JerryChang ,

I think the issue is somehow resolved as I realized that the interrupt signal for the IO Expander was not necessary (I use all of its IOs as outputs) so I removed it and modified the reset-gpios definition :

        i2c@31e0000 {
                status = "okay";
                #address-cells = <1>;
                #size-cells = <0>;

                mcp23008_27: gpio@27 {
                        compatible = "microchip,mcp23008";
                        gpio-controller;
                        #gpio-cells = <2>;
                        reg = <0x27>;
                        status = "okay";

                        //interrupt-parent = <&tegra_aon_gpio>;
                        //interrupts = <TEGRA194_AON_GPIO(CC, 3) IRQ_TYPE_EDGE_FALLING>;
                        //irq-gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 3) GPIO_ACTIVE_HIGH>;
                        //reset-gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Q, 3) GPIO_ACTIVE_HIGH>;
                        reset-gpios = <&tegra_main_gpio 438 GPIO_ACTIVE_HIGH>;
                        interrupt-controller;
                        #interrupt-cells=<2>;
                        microchip,irq-mirror;
                        microchip,irq-active-high;

                        mcp23008_27_output_low {
                                status = "disabled";
                        };

                        mcp23008_27_output_high {
                                gpio-hog;
                                output-high;
                                gpios = <1 0 2 0 3 0>;
                                label = "ioexp_adv_3v3_en", "ioexp_adv_reset", "ioexp_sony_reset";
                        };
                };
                ...
           };

And it gave :

rtr@ubuntu:~$ sudo dmesg | grep mcp
[sudo] password for rtr: 
[    7.576865] gpio-298 (mcp23008_27_output_high): hogged as output/high
[    7.577824] gpio-299 (mcp23008_27_output_high): hogged as output/high
[    7.578746] gpio-300 (mcp23008_27_output_high): hogged as output/high
[    7.579518] gpiochip3: registered GPIOs 297 to 304 on mcp23008
rtr@ubuntu:~$ sudo cat /sys/kernel/debug/gpio
gpiochip3: GPIOs 297-304, parent: i2c/8-0027, mcp23008, can sleep:
 gpio-298 (                    |mcp23008_27_output_h) in  hi 
 gpio-299 (                    |reset               ) out hi ACTIVE LOW
 gpio-300 (                    |mcp23008_27_output_h) in  hi 

However, I would still like to have your confirmation about my previous comment.

Thanks and best regards,
K.

hello khang.l4es,

please ignore my comment #11, I was messed up your use-case, will also revise my comments.
per your comment #14… yes, please use the GPIO number directly for current release.

1 Like

Hi @JerryChang,

Thanks for the confirmation!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.