1 1
John Henry

How to wakeup orange pi 3 via a gpio in CON12

Recommended Posts

(edited)

Hi, I want to use a gpio in CON12 to wakeup orange pi 3.  But I can not figure it out.

I am using armbian 5.4.43. I have done some researh about this question. 

It seems the basic process shoule be:

1、choose the right pin to wakeup. Cause some pins can not support interrupt and wakeup event. But I can not find which gpio support wakeup event.

It seems I should choose pin on PL or PM ports. But according the schmatic, lots of them have been used as other usages:

PIN DEFINE CFG

PL0

PMU-SCK 3
PL1 PMU-SDA 3
PL2 RECOVERY 2
PL3 LINK-LED 1
PL4 POW-LED 1
PL5 USB0-DRVVBUS 1
PL6 MUTE 1
PL7 STATUS-LED 1
PL8    
PL9 IR-RX 2
PL10 BT-WIFI-ON 1
PM0 WL-WAKE-AP 0
PM1 BT-WAKE-AP 0
PM2 AP-WAKE-AP 1

PM3

WL-REG-ON

1

 

PM4   BT-REG-ON 1

 

 

It seems only PL8 isavailable, but PL8 is also used as PWM pin

 

2、 write a dts file and let it using gpio-keys driver. For examples choose KEY_WAKEUP. But There need more detail about how to write dts files even after I read some examples. I don't know if I should choose "&pio" or "&r_pio". I can not find any file descript this part.

(I have found some descriptiion about PL port and others. &pio is used for PA~PK, &r_pio is used for PL port. And Only Pins on PL port can be used as wakeup source.)

(I have test PL8 and PL10. All of them return -22 after reboot when i user dmesg | grep to search gpio. I don't know if I have made some mistake)

/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun50i-h6";
/*
	 * This fragment is needed only for the internal pull-up activation,
	 * external pull-up resistor is highly recommended if using long wires
	 */
	fragment@0 {
		target = <&r_pio>;
		__overlay__ {
			gpio_key_wakeup: gpio_key_wakeup {
				pins = "PL8";
				function = "gpio_in";
				bias-pull-up;
			};
		};
	};

	fragment@1 {
		target-path = "/";
		__overlay__ {
			gpio-keys-user {
				/*
				 * Use "gpio-keys" for EINT capable pins, "gpio-keys-polled" for other pins
				 * add "poll-interval" property if using "gpio-keys-polled"
				 */
				compatible = "gpio-keys";
				pinctrl-names = "default";
				pinctrl-0 = <&gpio_key_wakeup>;

				key_wakeup{
					label = "GPIO KEY_WAKEUP";
					linux,code = <143>; /* KEY_WAKEUP, see include/uapi/linux/input-event-codes.h */
					gpios = <&r_pio 0 8 1>; /* PA10 GPIO_ACTIVE_LOW */
				};
			};
		};
	};
};

 

The error message is :

opi@orangepi3:~$ dmesg | grep -i gpio
[    2.642632] sun50i-h6-r-pinctrl 7022000.pinctrl: pin PL8 already requested by gpio-keys-user; cannot claim for 7022000.pinctrl:360
[    2.642646] gpio-keys gpio-keys-user: failed to get gpio: -22
[    2.642662] gpio-keys: probe of gpio-keys-user failed with error -22
[    3.343678] sunxi-mmc 4020000.mmc: Got CD GPIO

 

3、armbian describe we can use "armbian-add-ovelay" to add a custom dts to /boot/user_overlays. But if my dts file have some error if I can delete the relative file directly ? Or I need use other command?

(armbian-add-overlay is unavailable for H6 chip. We need to use dtc compile dts file to dtbo and then move it to /boot/overlay-user)

4、add the right ovelay to user-overlays line in /boot/armbianEnv.txt

I know it is a old question.  But I am so sorry as a  newbie can not draw s whole picture about how to use gpio-keys and device tree.

 

Anybody can give me some instructions? Thanks so much!

 

Edited by John Henry
Add more information

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
1 1