gpio-sim as a GPIO Interrupt for PMIC driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

gpio-sim as a GPIO Interrupt for PMIC driver

Jump to solution
2,254 Views
elFunko
Contributor III

Hi everyone,

I'm currently working on getting a custom i.MX93 board up and running, and I'm facing an issue with the PMIC (the NXP PCA9451A). The problem is that the PMIC requires a GPIO interrupt to load its driver, but our board does not have any free GPIOs available.

To solve this, we came up with the idea of using a "fake" GPIO through gpio-sim or gpio-mockup, so that we can get the PMIC up and running for now. In a future revision of the board, we plan to replace this mockup GPIO with a real one. However, I'm struggling to get the PMIC driver to load, regardless of how I configure the gpio-sim node.

I've seen a linux patch from 2022 "[PATCH v2 0/3] allow gpio simulator be used as interrupt controller ", which seems to be attempting the same thing I'm trying to do. We're currently using Linux version 6.6.28-lf-6.6.y-lf-6.6.y-g81ea508ca4b7-dirty.

I've also made sure to add the necessary kernel configuration options, including:

  • CONFIG_GPIO_SIM=y

  • CONFIG_GPIOLIB=y

  • CONFIG_IRQ_SIM=y

Despite this, the PMIC driver does not load. Below is how I'd like the PMIC node to look in the device tree, using gpio-sim as the interrupt parent:

&lpi2c1 {
    #address-cells = <1>;
    #size-cells = <0>;
    clock-frequency = <400000>;
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&pinctrl_lpi2c1>;
    pinctrl-1 = <&pinctrl_lpi2c1>;
    status = "okay";

    pmic@25 {
        compatible = "nxp,pca9451a";
        reg = <0x25>;
        interrupt-parent = <&gpio_sim>;
        interrupts = <0 IRQ_TYPE_EDGE_FALLING>;

Has anyone successfully used gpio-sim in a similar scenario, or can anyone suggest how the gpio-sim node should be configured to make this work?

Any help would be greatly appreciated!

Best regards,
Elia

 

Tags (2)
0 Kudos
Reply
1 Solution
2,158 Views
elFunko
Contributor III

To anyone having the same question I got it to work:

/ {
	gpio_sim {
		compatible = "gpio-simulator";

		bank0: bank0 {
			gpio-controller;
			#gpio-cells = <1>;
			ngpios = <1>;

			interrupt-controller;
			#interrupt-cells = <1>;
		};
	};
};

 

View solution in original post

0 Kudos
Reply
1 Reply
2,159 Views
elFunko
Contributor III

To anyone having the same question I got it to work:

/ {
	gpio_sim {
		compatible = "gpio-simulator";

		bank0: bank0 {
			gpio-controller;
			#gpio-cells = <1>;
			ngpios = <1>;

			interrupt-controller;
			#interrupt-cells = <1>;
		};
	};
};

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1972220%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Egpio-sim%20as%20a%20GPIO%20Interrupt%20for%20PMIC%20driver%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1972220%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHi%20everyone%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI'm%20currently%20working%20on%20getting%20a%20custom%20i.MX93%20board%20up%20and%20running%2C%20and%20I'm%20facing%20an%20issue%20with%20the%20PMIC%20(the%20NXP%20PCA9451A).%20The%20problem%20is%20that%20the%20PMIC%20requires%20a%20GPIO%20interrupt%20to%20load%20its%20driver%2C%20but%20our%20board%20does%20not%20have%20any%20free%20GPIOs%20available.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ETo%20solve%20this%2C%20we%20came%20up%20with%20the%20idea%20of%20using%20a%20%22fake%22%20GPIO%20through%20gpio-sim%20or%20gpio-mockup%2C%20so%20that%20we%20can%20get%20the%20PMIC%20up%20and%20running%20for%20now.%20In%20a%20future%20revision%20of%20the%20board%2C%20we%20plan%20to%20replace%20this%20mockup%20GPIO%20with%20a%20real%20one.%20However%2C%20I'm%20struggling%20to%20get%20the%20PMIC%20driver%20to%20load%2C%20regardless%20of%20how%20I%20configure%20the%20gpio-sim%20node.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI've%20seen%20a%20linux%20patch%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bfrom%202022%20%22%5BPATCH%20v2%200%2F3%5D%20allow%20gpio%20simulator%20be%20used%20as%20interrupt%20controller%20%22%2C%20which%20seems%20to%20be%20attempting%20the%20same%20thing%20I'm%20trying%20to%20do.%20We're%20currently%20using%20Linux%20version%206.6.28-lf-6.6.y-lf-6.6.y-g81ea508ca4b7-dirty.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI've%20also%20made%20sure%20to%20add%20the%20necessary%20kernel%20configuration%20options%2C%20including%3A%3C%2FSPAN%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CP%3E%3CSPAN%3ECONFIG_GPIO_SIM%3Dy%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSPAN%3ECONFIG_GPIOLIB%3Dy%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSPAN%3ECONFIG_IRQ_SIM%3Dy%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSPAN%3EDespite%20this%2C%20the%20PMIC%20driver%20does%20not%20load.%20Below%20is%20how%20I'd%20like%20the%20PMIC%20node%20to%20look%20in%20the%20device%20tree%2C%20using%20gpio-sim%20as%20the%20interrupt%20parent%3A%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%26amp%3Blpi2c1%20%7B%0A%20%20%20%20%23address-cells%20%3D%20%26lt%3B1%26gt%3B%3B%0A%20%20%20%20%23size-cells%20%3D%20%26lt%3B0%26gt%3B%3B%0A%20%20%20%20clock-frequency%20%3D%20%26lt%3B400000%26gt%3B%3B%0A%20%20%20%20pinctrl-names%20%3D%20%22default%22%2C%20%22sleep%22%3B%0A%20%20%20%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinctrl_lpi2c1%26gt%3B%3B%0A%20%20%20%20pinctrl-1%20%3D%20%26lt%3B%26amp%3Bpinctrl_lpi2c1%26gt%3B%3B%0A%20%20%20%20status%20%3D%20%22okay%22%3B%0A%0A%20%20%20%20pmic%4025%20%7B%0A%20%20%20%20%20%20%20%20compatible%20%3D%20%22nxp%2Cpca9451a%22%3B%0A%20%20%20%20%20%20%20%20reg%20%3D%20%26lt%3B0x25%26gt%3B%3B%0A%20%20%20%20%20%20%20%20interrupt-parent%20%3D%20%26lt%3B%26amp%3Bgpio_sim%26gt%3B%3B%0A%20%20%20%20%20%20%20%20interrupts%20%3D%20%26lt%3B0%20IRQ_TYPE_EDGE_FALLING%26gt%3B%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%3EHas%20anyone%20successfully%20used%20gpio-sim%20in%20a%20similar%20scenario%2C%20or%20can%20anyone%20suggest%20how%20the%20gpio-sim%20node%20should%20be%20configured%20to%20make%20this%20work%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAny%20help%20would%20be%20greatly%20appreciated!%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EBest%20regards%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EElia%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1993513%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20gpio-sim%20as%20a%20GPIO%20Interrupt%20for%20PMIC%20driver%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1993513%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ETo%20anyone%20having%20the%20same%20question%20I%20got%20it%20to%20work%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%2F%20%7B%0A%09gpio_sim%20%7B%0A%09%09compatible%20%3D%20%22gpio-simulator%22%3B%0A%0A%09%09bank0%3A%20bank0%20%7B%0A%09%09%09gpio-controller%3B%0A%09%09%09%23gpio-cells%20%3D%20%26lt%3B1%26gt%3B%3B%0A%09%09%09ngpios%20%3D%20%26lt%3B1%26gt%3B%3B%0A%0A%09%09%09interrupt-controller%3B%0A%09%09%09%23interrupt-cells%20%3D%20%26lt%3B1%26gt%3B%3B%0A%09%09%7D%3B%0A%09%7D%3B%0A%7D%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E