Config Jetson Nano Pin pcc4 as mcp2515 interrupt pin problem

Hi!
I have connect mcp2515 module to jetson nano 4gb board, follow the guide: Unofficial Guide to using the MCP2515 can module on the Jetson Nano .
The mcp2515 works with the pin connect same as guide mention. When I change the interrupt pin from PZ0 to PCC4, the problem came out. I found the problem maybe is the Pin(PCC4) has already occupy by the extcon driver. I try to set the pcc4(pin228) by

    echo 228 > /sys/class/gpio/export. 

And I got follow output:

Write error: Device or resource busy.

I look through file : cat /sys/kernal/debug/gpio find out gpio-228 seemd occupy by extcon:

gpio-228 (                    |extcon:extcon@1     ) in  hi IRQ

I want to change the extcon gpio pin. So I try to recompile the dtb file(tegra210-p3448-0000-p3449-0000-b00.dtb) and reconfig the
extcon@1 gpio setting as follow:

extcon@1 {
			compatible = "extcon-gpio-states";
			reg = <0x1>;
			extcon-gpio,name = "VBUS";
			extcon-gpio,cable-states = <0x0 0x1 0x1 0x0>;
			gpios = <0x5b **0xe5** 0x0>;
			extcon-gpio,out-cable-names = <0x1 0x2 0x0>;
			wakeup-source;
			#extcon-cells = <0x1>;
			nvidia,pmc-wakeup = <0x3c 0x0 0x36 0x0>;
			linux,phandle = <0x4d>;
			phandle = <0x4d>;
		};

Then, I copy the compiled refine dtb file to the /boot/ folder and reboot the nano. The problem still there.

cat /proc/interrupts
>   327:          0          0          0          0      GPIO 228 Edge      extcon:extcon@1

I want to know could I use pcc4(usb_vbus_en0_pcc4) pin as an interrupt of mcp2515 ? How to disable the extcon driver to release the pcc4 pin?
By the way, the usb_vbus_en0_pcc4 pin descript is generate by the spreadsheet of jetson nano as follow:

usb_vbus_en0_pcc4 {
				nvidia,pins = "usb_vbus_en0_pcc4";
				nvidia,function = "rsvd1";
				nvidia,pull = <0x0>;
				nvidia,tristate = <0x1>;
				nvidia,enable-input = <0x1>;
				nvidia,io-high-voltage = <0x0>;
			};

Thanks.
BR

hello qpeng05041,

you may modify device tree and also revise the driver side for not using this pin.

Hello JerryChang,
Thanks you for reply my question. I don’t familiar with the device tree and extcon driver.
I try to modify the device tree as follow, but none of the methods can release the pcc4 pin.

extcon@1 {
			compatible = "extcon-gpio-states";
			status = "disabled";			
			reg = <0x1>;
			extcon-gpio,name = "VBUS";
			extcon-gpio,cable-states = <0x0 0x1 0x1 0x0>;
			//gpios = <0x5b 0xe5 0x0>;              ------------------------------modify here ----------------------------
			extcon-gpio,out-cable-names = <0x1 0x2 0x0>;
			wakeup-source;
			#extcon-cells = <0x1>;
			nvidia,pmc-wakeup = <0x3c 0x0 0x36 0x0>;
			linux,phandle = <0x4d>;
			phandle = <0x4d>;
		};
chosen {
		nvidia,tegra-porg-sku;
		stdout-path = "/serial@70006000";
		nvidia,tegra-always-on-personality;
		no-tnid-sn;
		bootargs = "earlycon=uart8250,mmio32,0x70006000";
		nvidia,bootloader-vbus-enable = <0>;       ------------------------------modify here ----------------------------
		nvidia,fastboot_without_usb;
		nvidia,gpu-disable-power-saving;
		board-has-eeprom;
		firmware-blob-partition = "RP4";

		plugin-manager {
		};

		verified-boot {
			poweroff-on-red-state;
		};
	};
xudc@700d0000 {
		compatible = "nvidia,tegra210-xudc";
		reg = <0x0 0x700d0000 0x0 0x8000 0x0 0x700d8000 0x0 0x1000 0x0 0x700d9000 0x0 0x1000>;
		interrupts = <0x0 0x2c 0x4>;
		clocks = <0x26 0x121 0x26 0x9c 0x26 0x13e 0x26 0x122 0x26 0x11e>;
		nvidia,xusb-padctl = <0x49>;
		iommus = <0x30 0x15>;
		status = "okay";
		charger-detector = <0x9e>;
		hvdd_usb-supply = <0x4c>;
		avdd_pll_utmip-supply = <0x3b>;
		avddio_usb-supply = <0x44>;
		avddio_pll_uerefe-supply = <0x43>;
		//extcon-cables = <0x4d 0x1>;           ------------------------------modify here ----------------------------
		//extcon-cable-names = "vbus";         ------------------------------modify here ----------------------------
		phys = <0x4a>;
		phy-names = "usb2";
		#extcon-cells = <0x1>;
	};
xusb@70090000 {
		compatible = "nvidia,tegra210-xhci";
		reg = <0x0 0x70090000 0x0 0x8000 0x0 0x70098000 0x0 0x1000 0x0 0x70099000 0x0 0x1000>;
		interrupts = <0x0 0x27 0x4 0x0 0x28 0x4 0x0 0x31 0x4>;
		nvidia,xusb-padctl = <0x49>;
		clocks = <0x26 0x59 0x26 0x11d 0x26 0x9c 0x26 0x11f 0x26 0x122 0x26 0x11e 0x26 0xff 0x26 0xe9 0x26 0x107>;
		clock-names = "xusb_host", "xusb_falcon_src", "xusb_ss", "xusb_ss_src", "xusb_hs_src", "xusb_fs_src", "pll_u_480m", "clk_m", "pll_e";
		iommus = <0x30 0x14>;
		status = "okay";
		hvdd_usb-supply = <0x4c>;
		avdd_pll_utmip-supply = <0x3b>;
		vddio_hsic-supply = <0x42>;
		avddio_usb-supply = <0x44>;
		dvdd_sata-supply = <0x45>;
		avddio_pll_uerefe-supply = <0x43>;
		//extcon-cables = <0x4c 0x1>;              ------------------------------modify here ----------------------------
		//extcon-cable-names = "id";                ------------------------------modify here ----------------------------
		phys = <0x4a 0x4e 0x4f 0x50>;
		phy-names = "usb2-0", "usb2-1", "usb2-2", "usb3-0";
		//#extcon-cells = <0x1>;
		nvidia,pmc-wakeup = <0x3c 0x1 0x27 0x4 0x3c 0x1 0x28 0x4 0x3c 0x1 0x29 0x4 0x3c 0x1 0x2a 0x4 0x3c 0x1 0x2c 0x4>;
		nvidia,boost_cpu_freq = <0x4b0>;
	};

I wonder that if I just modify the vbus to another pin, or disable the extcon function in the device tree only, pin pcc4 or gpio 228 will not be occupied by extcon: extcon@1. Is the extcon driver must be revise? Is the device tree determind the extcon@1 interrupt pin(gpio228)?

327:          0          0          0          0      GPIO 228 Edge      extcon:extcon@1

Thanks

Since you said you are not familiar with device tree, then I wonder what is your method to update device tree after you changed it?

I recompile the dtb file(tegra210-p3448-0000-p3449-0000-b00.dtb) to get .dts file, using following command:

 dtc -I dtb -O dts -o my-overlay.dts /boot/tegra210-p3448-0000-p3449-0000-b00.dtb

After reconfig the dts file, I use flollowing command:

dtc -O dtb -o tegra210-p3448-0000-p3449-0000-b00.dtbo -@ my-overlay.dts
sudo cp tegra210-p3448-0000-p3449-0000-b00.dtbo /boot
sudo reboot

By default, the dtb file is not read from rootfs. Which means what you are doing does not update the dtb.

You can either update it from host (re-flash is required) or add FDT field to your /boot/extlinux/extlinux.conf.

Hi WayneWWW,
I am extremely grateful for your help!!!
After I change the extcon@1 property in file (kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb), It works.
Later, I will try to use another methods you have mentioned. Thanks again!!!

1 Like

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