Merge pull request #5 from r3claimer/dev

RK3566 input patches
This commit is contained in:
r3claimer 2024-03-25 23:03:49 -07:00 committed by GitHub
commit 94a2b05d65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 896 additions and 20 deletions

View file

@ -1,20 +0,0 @@
--- a/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg503.dts 2024-03-15 18:26:31.236348216 +0300
+++ b/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg503.dts 2024-03-15 18:26:48.664293252 +0300
@@ -139,7 +139,7 @@
&gpio_keys_control {
button-a {
- gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
+ gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
label = "EAST";
linux,code = <BTN_EAST>;
};
@@ -175,7 +175,7 @@
};
button-y {
- gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
+ gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
label = "WEST";
linux,code = <BTN_WEST>;
};

View file

@ -0,0 +1,171 @@
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353vs.dts linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353vs.dts
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353vs.dts 2024-03-26 04:17:51.534641800 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353vs.dts 2024-03-26 04:25:37.989710946 +0000
@@ -61,19 +61,156 @@
sound-dai = <&i2s1_8ch>;
};
};
-};
-&gpio_keys_control {
- button-r1 {
- gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
- label = "TR";
- linux,code = <BTN_TR>;
- };
+ joypad: singleadc-joypad {
+ compatible = "singleadc-joypad";
+ hw_info = <0x02>;
+
+ joypad-name = "retrogame_joypad";
+ joypad-product = <0x1101>;
+ joypad-revision = <0x0100>;
+
+ status = "okay";
+
+ /* gpio pincontrol setup */
+ pinctrl-names = "default";
+ pinctrl-0 = <&btn_pins_ctrl>;
+
+ /* Analog mux define */
+ io-channel-names = "amux_adc";
+ io-channels = <&saradc 3>;
+
+ /* adc mux channel count */
+ amux-count = <4>;
+ /* adc mux select(a,b) gpio */
+ amux-a-gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>;
+ amux-b-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_LOW>;
+ /* adc mux enable gpio */
+ amux-en-gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_LOW>;
+
+ /* adc calculate scale */
+ button-adc-scale = <2>;
- button-r2 {
- gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
- label = "TR2";
- linux,code = <BTN_TR2>;
+ /* adc deadzone range */
+ button-adc-deadzone = <64>;
+
+ /*
+ specifies fuzz value that is used to filter noise from
+ the event stream.
+ */
+ button-adc-fuzz = <32>;
+ button-adc-flat = <32>;
+
+ /*
+ Analog Stick data tuning value(precent)
+ p = positive direction, n = negative direction
+ report value = (real_adc_data * tuning_value) / 100
+ */
+ abs_x-p-tuning = <245>;
+ abs_x-n-tuning = <245>;
+
+ abs_y-p-tuning = <245>;
+ abs_y-n-tuning = <245>;
+
+ abs_rx-p-tuning = <245>;
+ abs_rx-n-tuning = <245>;
+
+ abs_ry-p-tuning = <245>;
+ abs_ry-n-tuning = <245>;
+
+ /* poll device interval (ms), adc read interval */
+ poll-interval = <10>;
+
+ /* gpio button auto repeat set value : default disable */
+ /*
+ autorepeat;
+ */
+ sw1 {
+ gpios = <&gpio3 RK_PA3 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-UP";
+ linux,code = <BTN_DPAD_UP>;
+ };
+ sw2 {
+ gpios = <&gpio3 RK_PA4 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-DOWN";
+ linux,code = <BTN_DPAD_DOWN>;
+ };
+ sw3 {
+ gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-LEFT";
+ linux,code = <BTN_DPAD_LEFT>;
+ };
+ sw4 {
+ gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-RIGHT";
+ linux,code = <BTN_DPAD_RIGHT>;
+ };
+ sw5 {
+ gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>;
+ label = "GPIO KEY BTN-A";
+ linux,code = <BTN_SOUTH>;
+ };
+ sw6 {
+ gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-B";
+ linux,code = <BTN_EAST>;
+ };
+ sw7 {
+ gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-X";
+ linux,code = <BTN_NORTH>;
+ };
+ sw8 {
+ gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-Y";
+ linux,code = <BTN_WEST>;
+ };
+ sw9 {
+ gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_SELECT";
+ linux,code = <BTN_SELECT>;
+ };
+ sw10 {
+ gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_START";
+ linux,code = <BTN_START>;
+ };
+ sw11 {
+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_F";
+ linux,code = <BTN_MODE>;
+ };
+ sw12 {
+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL";
+ linux,code = <BTN_TL>;
+ };
+ sw13 {
+ gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR";
+ linux,code = <BTN_TR>;
+ };
+ sw14 {
+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL2";
+ linux,code = <BTN_TL2>;
+ };
+ sw15 {
+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR2";
+ linux,code = <BTN_TR2>;
+ };
+ sw16 {
+ gpios = <&gpio3 RK_PA1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBL";
+ linux,code = <BTN_THUMBL>;
+ };
+ sw17 {
+ gpios = <&gpio3 RK_PA2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBR";
+ linux,code = <BTN_THUMBR>;
+ };
+
};
};

View file

@ -0,0 +1,211 @@
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg503.dts linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg503.dts
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg503.dts 2024-03-26 04:17:51.534641800 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg503.dts 2024-03-26 04:51:03.363007171 +0000
@@ -102,6 +102,156 @@
pinctrl-names = "default";
sound-name-prefix = "Speaker Amp";
};
+
+ joypad: singleadc-joypad {
+ compatible = "singleadc-joypad";
+
+ joypad-name = "retrogame_joypad";
+ joypad-product = <0x1101>;
+ joypad-revision = <0x0100>;
+
+ status = "okay";
+
+ /* gpio pincontrol setup */
+ pinctrl-names = "default";
+ pinctrl-0 = <&btn_pins_ctrl>;
+
+ /* Analog mux define */
+ io-channel-names = "amux_adc";
+ io-channels = <&saradc 3>;
+
+ /* adc mux channel count */
+ amux-count = <4>;
+ /* adc mux select(a,b) gpio */
+ amux-a-gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>;
+ amux-b-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_LOW>;
+ /* adc mux enable gpio */
+ amux-en-gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_LOW>;
+
+ /* adc calculate scale */
+ button-adc-scale = <2>;
+
+ /* adc deadzone range */
+ button-adc-deadzone = <64>;
+
+ /*
+ specifies fuzz value that is used to filter noise from
+ the event stream.
+ */
+ button-adc-fuzz = <32>;
+ button-adc-flat = <32>;
+
+ /*
+ Analog Stick data tuning value(precent)
+ p = positive direction, n = negative direction
+ report value = (real_adc_data * tuning_value) / 100
+ */
+ abs_x-p-tuning = <450>;
+ abs_x-n-tuning = <450>;
+
+ abs_y-p-tuning = <450>;
+ abs_y-n-tuning = <450>;
+
+ abs_rx-p-tuning = <450>;
+ abs_rx-n-tuning = <450>;
+
+ abs_ry-p-tuning = <450>;
+ abs_ry-n-tuning = <450>;
+
+ /* poll device interval (ms), adc read interval */
+ poll-interval = <10>;
+
+ /* gpio button auto repeat set value : default disable */
+ /*
+ autorepeat;
+ */
+ sw1 {
+ gpios = <&gpio3 RK_PA3 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-UP";
+ linux,code = <BTN_DPAD_UP>;
+ };
+ sw2 {
+ gpios = <&gpio3 RK_PA4 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-DOWN";
+ linux,code = <BTN_DPAD_DOWN>;
+ };
+ sw3 {
+ gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-LEFT";
+ linux,code = <BTN_DPAD_LEFT>;
+ };
+ sw4 {
+ gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-RIGHT";
+ linux,code = <BTN_DPAD_RIGHT>;
+ };
+ sw5 {
+ gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>;
+ label = "GPIO KEY BTN-A";
+ linux,code = <BTN_SOUTH>;
+ };
+ sw6 {
+ gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-B";
+ linux,code = <BTN_EAST>;
+ };
+ sw7 {
+ gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-X";
+ linux,code = <BTN_NORTH>;
+ };
+ sw8 {
+ gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-Y";
+ linux,code = <BTN_WEST>;
+ };
+ sw9 {
+ gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_SELECT";
+ linux,code = <BTN_SELECT>;
+ };
+ sw10 {
+ gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_START";
+ linux,code = <BTN_START>;
+ };
+ sw11 {
+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_F";
+ linux,code = <BTN_MODE>;
+ };
+ sw12 {
+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL";
+ linux,code = <BTN_TL>;
+ };
+ sw13 {
+ gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR";
+ linux,code = <BTN_TR>;
+ };
+ sw14 {
+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL2";
+ linux,code = <BTN_TL2>;
+ };
+ sw15 {
+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR2";
+ linux,code = <BTN_TR2>;
+ };
+ sw16 {
+ gpios = <&gpio3 RK_PA1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBL";
+ linux,code = <BTN_THUMBL>;
+ };
+ sw17 {
+ gpios = <&gpio3 RK_PA2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBR";
+ linux,code = <BTN_THUMBR>;
+ };
+
+ };
};
&cru {
@@ -137,50 +287,6 @@
};
};
-&gpio_keys_control {
- button-a {
- gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
- label = "EAST";
- linux,code = <BTN_EAST>;
- };
-
- button-left {
- gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
- label = "DPAD-LEFT";
- linux,code = <BTN_DPAD_LEFT>;
- };
-
- button-right {
- gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
- label = "DPAD-RIGHT";
- linux,code = <BTN_DPAD_RIGHT>;
- };
-
- button-r1 {
- gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
- label = "TR";
- linux,code = <BTN_TR>;
- };
-
- button-r2 {
- gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
- label = "TR2";
- linux,code = <BTN_TR2>;
- };
-
- button-right {
- gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
- label = "DPAD-RIGHT";
- linux,code = <BTN_DPAD_RIGHT>;
- };
-
- button-y {
- gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
- label = "WEST";
- linux,code = <BTN_WEST>;
- };
-};
-
&pinctrl {
audio-amplifier {
spk_amp_enable_h: spk-amp-enable-h {

View file

@ -0,0 +1,173 @@
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353v.dts linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353v.dts
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353v.dts 2024-03-26 04:17:51.534641800 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353v.dts 2024-03-26 05:25:52.199838520 +0000
@@ -62,20 +62,158 @@
sound-dai = <&i2s1_8ch>;
};
};
-};
-&gpio_keys_control {
- button-r1 {
- gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
- label = "TR";
- linux,code = <BTN_TR>;
- };
+ joypad: singleadc-joypad {
+ compatible = "singleadc-joypad";
+ hw_info = <0x02>;
+
+ joypad-name = "retrogame_joypad";
+ joypad-product = <0x1101>;
+ joypad-revision = <0x0100>;
+
+ status = "okay";
+
+ /* gpio pincontrol setup */
+ pinctrl-names = "default";
+ pinctrl-0 = <&btn_pins_ctrl>;
+
+ /* Analog mux define */
+ io-channel-names = "amux_adc";
+ io-channels = <&saradc 3>;
+
+ /* adc mux channel count */
+ amux-count = <4>;
+ /* adc mux select(a,b) gpio */
+ amux-a-gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>;
+ amux-b-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_LOW>;
+ /* adc mux enable gpio */
+ amux-en-gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_LOW>;
+
+ /* adc calculate scale */
+ button-adc-scale = <2>;
+
+ /* adc deadzone range */
+ button-adc-deadzone = <64>;
- button-r2 {
- gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
- label = "TR2";
- linux,code = <BTN_TR2>;
+ /*
+ specifies fuzz value that is used to filter noise from
+ the event stream.
+ */
+ button-adc-fuzz = <32>;
+ button-adc-flat = <32>;
+
+ /*
+ Analog Stick data tuning value(precent)
+ p = positive direction, n = negative direction
+ report value = (real_adc_data * tuning_value) / 100
+ */
+ abs_x-p-tuning = <245>;
+ abs_x-n-tuning = <245>;
+
+ abs_y-p-tuning = <245>;
+ abs_y-n-tuning = <245>;
+
+ abs_rx-p-tuning = <245>;
+ abs_rx-n-tuning = <245>;
+
+ abs_ry-p-tuning = <245>;
+ abs_ry-n-tuning = <245>;
+
+ /* poll device interval (ms), adc read interval */
+ poll-interval = <10>;
+
+ /* gpio button auto repeat set value : default disable */
+ /*
+ autorepeat;
+ */
+ sw1 {
+ gpios = <&gpio3 RK_PA3 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-UP";
+ linux,code = <BTN_DPAD_UP>;
+ };
+ sw2 {
+ gpios = <&gpio3 RK_PA4 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-DOWN";
+ linux,code = <BTN_DPAD_DOWN>;
+ };
+ sw3 {
+ gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-LEFT";
+ linux,code = <BTN_DPAD_LEFT>;
+ };
+ sw4 {
+ gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-RIGHT";
+ linux,code = <BTN_DPAD_RIGHT>;
+ };
+ sw5 {
+ gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>;
+ label = "GPIO KEY BTN-A";
+ linux,code = <BTN_SOUTH>;
+ };
+ sw6 {
+ gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-B";
+ linux,code = <BTN_EAST>;
+ };
+ sw7 {
+ gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-X";
+ linux,code = <BTN_NORTH>;
+ };
+ sw8 {
+ gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-Y";
+ linux,code = <BTN_WEST>;
+ };
+ sw9 {
+ gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_SELECT";
+ linux,code = <BTN_SELECT>;
+ };
+ sw10 {
+ gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_START";
+ linux,code = <BTN_START>;
+ };
+ sw11 {
+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_F";
+ linux,code = <BTN_MODE>;
+ };
+ sw12 {
+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL";
+ linux,code = <BTN_TL>;
+ };
+ sw13 {
+ gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR";
+ linux,code = <BTN_TR>;
+ };
+ sw14 {
+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL2";
+ linux,code = <BTN_TL2>;
+ };
+ sw15 {
+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR2";
+ linux,code = <BTN_TR2>;
+ };
+ sw16 {
+ gpios = <&gpio3 RK_PA1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBL";
+ linux,code = <BTN_THUMBL>;
+ };
+ sw17 {
+ gpios = <&gpio3 RK_PA2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBR";
+ linux,code = <BTN_THUMBR>;
+ };
+
};
+
};
&i2c2 {

View file

@ -0,0 +1,171 @@
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353p.dts linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353p.dts
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353p.dts 2024-03-26 04:17:51.534641800 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353p.dts 2024-03-26 05:29:29.179313507 +0000
@@ -75,19 +75,156 @@
pinctrl-names = "default";
sound-name-prefix = "Speaker Amp";
};
-};
-&gpio_keys_control {
- button-r1 {
- gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
- label = "TR";
- linux,code = <BTN_TR>;
- };
+ joypad: singleadc-joypad {
+ compatible = "singleadc-joypad";
+ hw_info = <0x01>;
+
+ joypad-name = "retrogame_joypad";
+ joypad-product = <0x1101>;
+ joypad-revision = <0x0100>;
+
+ status = "okay";
+
+ /* gpio pincontrol setup */
+ pinctrl-names = "default";
+ pinctrl-0 = <&btn_pins_ctrl>;
+
+ /* Analog mux define */
+ io-channel-names = "amux_adc";
+ io-channels = <&saradc 3>;
+
+ /* adc mux channel count */
+ amux-count = <4>;
+ /* adc mux select(a,b) gpio */
+ amux-a-gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>;
+ amux-b-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_LOW>;
+ /* adc mux enable gpio */
+ amux-en-gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_LOW>;
+
+ /* adc calculate scale */
+ button-adc-scale = <2>;
+
+ /* adc deadzone range */
+ button-adc-deadzone = <64>;
+
+ /*
+ specifies fuzz value that is used to filter noise from
+ the event stream.
+ */
+ button-adc-fuzz = <32>;
+ button-adc-flat = <32>;
+
+ /*
+ Analog Stick data tuning value(precent)
+ p = positive direction, n = negative direction
+ report value = (real_adc_data * tuning_value) / 100
+ */
+ abs_x-p-tuning = <245>;
+ abs_x-n-tuning = <245>;
+
+ abs_y-p-tuning = <245>;
+ abs_y-n-tuning = <245>;
+
+ abs_rx-p-tuning = <245>;
+ abs_rx-n-tuning = <245>;
+
+ abs_ry-p-tuning = <245>;
+ abs_ry-n-tuning = <245>;
+
+ /* poll device interval (ms), adc read interval */
+ poll-interval = <10>;
- button-r2 {
- gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
- label = "TR2";
- linux,code = <BTN_TR2>;
+ /* gpio button auto repeat set value : default disable */
+ /*
+ autorepeat;
+ */
+ sw1 {
+ gpios = <&gpio3 RK_PA3 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-UP";
+ linux,code = <BTN_DPAD_UP>;
+ };
+ sw2 {
+ gpios = <&gpio3 RK_PA4 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-DOWN";
+ linux,code = <BTN_DPAD_DOWN>;
+ };
+ sw3 {
+ gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-LEFT";
+ linux,code = <BTN_DPAD_LEFT>;
+ };
+ sw4 {
+ gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-RIGHT";
+ linux,code = <BTN_DPAD_RIGHT>;
+ };
+ sw5 {
+ gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>;
+ label = "GPIO KEY BTN-A";
+ linux,code = <BTN_SOUTH>;
+ };
+ sw6 {
+ gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-B";
+ linux,code = <BTN_EAST>;
+ };
+ sw7 {
+ gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-X";
+ linux,code = <BTN_NORTH>;
+ };
+ sw8 {
+ gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-Y";
+ linux,code = <BTN_WEST>;
+ };
+ sw9 {
+ gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_SELECT";
+ linux,code = <BTN_SELECT>;
+ };
+ sw10 {
+ gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_START";
+ linux,code = <BTN_START>;
+ };
+ sw11 {
+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_F";
+ linux,code = <BTN_MODE>;
+ };
+ sw12 {
+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL";
+ linux,code = <BTN_TL>;
+ };
+ sw13 {
+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR";
+ linux,code = <BTN_TR>;
+ };
+ sw14 {
+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL2";
+ linux,code = <BTN_TL2>;
+ };
+ sw15 {
+ gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR2";
+ linux,code = <BTN_TR2>;
+ };
+ sw16 {
+ gpios = <&gpio3 RK_PA1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBL";
+ linux,code = <BTN_THUMBL>;
+ };
+ sw17 {
+ gpios = <&gpio3 RK_PA2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBR";
+ linux,code = <BTN_THUMBR>;
+ };
+
};
};

View file

@ -0,0 +1,170 @@
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353ps.dts linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353ps.dts
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353ps.dts 2024-03-26 04:17:51.534641800 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3566-anbernic-rg353ps.dts 2024-03-26 05:31:21.679144829 +0000
@@ -74,19 +74,155 @@
pinctrl-names = "default";
sound-name-prefix = "Speaker Amp";
};
-};
+ joypad: singleadc-joypad {
+ compatible = "singleadc-joypad";
+ hw_info = <0x01>;
-&gpio_keys_control {
- button-r1 {
- gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
- label = "TR";
- linux,code = <BTN_TR>;
- };
+ joypad-name = "retrogame_joypad";
+ joypad-product = <0x1101>;
+ joypad-revision = <0x0100>;
+
+ status = "okay";
+
+ /* gpio pincontrol setup */
+ pinctrl-names = "default";
+ pinctrl-0 = <&btn_pins_ctrl>;
+
+ /* Analog mux define */
+ io-channel-names = "amux_adc";
+ io-channels = <&saradc 3>;
+
+ /* adc mux channel count */
+ amux-count = <4>;
+ /* adc mux select(a,b) gpio */
+ amux-a-gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>;
+ amux-b-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_LOW>;
+ /* adc mux enable gpio */
+ amux-en-gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_LOW>;
+
+ /* adc calculate scale */
+ button-adc-scale = <2>;
+
+ /* adc deadzone range */
+ button-adc-deadzone = <64>;
+
+ /*
+ specifies fuzz value that is used to filter noise from
+ the event stream.
+ */
+ button-adc-fuzz = <32>;
+ button-adc-flat = <32>;
+
+ /*
+ Analog Stick data tuning value(precent)
+ p = positive direction, n = negative direction
+ report value = (real_adc_data * tuning_value) / 100
+ */
+ abs_x-p-tuning = <245>;
+ abs_x-n-tuning = <245>;
+
+ abs_y-p-tuning = <245>;
+ abs_y-n-tuning = <245>;
+
+ abs_rx-p-tuning = <245>;
+ abs_rx-n-tuning = <245>;
+
+ abs_ry-p-tuning = <245>;
+ abs_ry-n-tuning = <245>;
+
+ /* poll device interval (ms), adc read interval */
+ poll-interval = <10>;
- button-r2 {
- gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
- label = "TR2";
- linux,code = <BTN_TR2>;
+ /* gpio button auto repeat set value : default disable */
+ /*
+ autorepeat;
+ */
+ sw1 {
+ gpios = <&gpio3 RK_PA3 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-UP";
+ linux,code = <BTN_DPAD_UP>;
+ };
+ sw2 {
+ gpios = <&gpio3 RK_PA4 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-DOWN";
+ linux,code = <BTN_DPAD_DOWN>;
+ };
+ sw3 {
+ gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-LEFT";
+ linux,code = <BTN_DPAD_LEFT>;
+ };
+ sw4 {
+ gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
+ label = "GPIO DPAD-RIGHT";
+ linux,code = <BTN_DPAD_RIGHT>;
+ };
+ sw5 {
+ gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>;
+ label = "GPIO KEY BTN-A";
+ linux,code = <BTN_SOUTH>;
+ };
+ sw6 {
+ gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-B";
+ linux,code = <BTN_EAST>;
+ };
+ sw7 {
+ gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-X";
+ linux,code = <BTN_NORTH>;
+ };
+ sw8 {
+ gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN-Y";
+ linux,code = <BTN_WEST>;
+ };
+ sw9 {
+ gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_SELECT";
+ linux,code = <BTN_SELECT>;
+ };
+ sw10 {
+ gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_START";
+ linux,code = <BTN_START>;
+ };
+ sw11 {
+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_F";
+ linux,code = <BTN_MODE>;
+ };
+ sw12 {
+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL";
+ linux,code = <BTN_TL>;
+ };
+ sw13 {
+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR";
+ linux,code = <BTN_TR>;
+ };
+ sw14 {
+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TL2";
+ linux,code = <BTN_TL2>;
+ };
+ sw15 {
+ gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_TR2";
+ linux,code = <BTN_TR2>;
+ };
+ sw16 {
+ gpios = <&gpio3 RK_PA1 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBL";
+ linux,code = <BTN_THUMBL>;
+ };
+ sw17 {
+ gpios = <&gpio3 RK_PA2 GPIO_ACTIVE_LOW>;
+ label = "GPIO BTN_THUMBR";
+ linux,code = <BTN_THUMBR>;
+ };
+
};
};